Вопрос

I have this function for setting cookies, it works GREAT on all browsers, but it in ie7 it simply doesn't save the cookie.

Any ideas why?

(the input to the function is valid, I tripled checked it)

function SetCookie(cookieName, cookieValue, nDays) {
    try {
        var today = new Date();
        var expire = new Date();
        if (nDays == null || nDays == 0) nDays = 1;
        expire.setTime(today.getTime() + 3600000 * 24 * nDays);
        var newCookie = cookieName + '=' + cookieValue + '; expires=' + expire.toGMTString()+'; path=/';
        document.cookie = newCookie;
    } catch (e) {
        showAlert('SetCookie:' + e.message);
    }
}
Это было полезно?

Решение

I found the answer and it happened only on ie 7, 8.

I have several sub domains on my dev and qa environment like: dev.site.com qa.site.com developerName.site.com

and of course site.com

I noticed that if you log in to any sub domain the cookie is ok, but when you go to regular domain it messes up the sub domains cookies.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top