SheppardDigital
asked on
Javascript cookies clear the next day
Hi, we're trying to set a cookie using javascript that doesn't expiry for at least 6 month.
We're using this function to set a cookie
function setCookie(name, value, seconds) {
if (typeof(seconds) != 'undefined') {
var date = new Date();
date.setTime(date.getTime( ) + (seconds*1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
document.cookie = name+"="+value+expires+"; path=/";
}
and then this to initiate the cookie...
setCookie('resources_user_ id',respon se,1577846 3);
The cookie seems to work ok until the next day when you log into the site and the cookie has been cleared.
Am I doing something wrong?
We're using this function to set a cookie
function setCookie(name, value, seconds) {
if (typeof(seconds) != 'undefined') {
var date = new Date();
date.setTime(date.getTime(
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
document.cookie = name+"="+value+expires+"; path=/";
}
and then this to initiate the cookie...
setCookie('resources_user_
The cookie seems to work ok until the next day when you log into the site and the cookie has been cleared.
Am I doing something wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.