Maximum LifeTime of javascript cookie
Read : Expires and Max-Age of Cookies
Life time of the javascript cookies is depend on what amount of time you set when creating cookies for example following set the life time of 10 minutes
expiry = new Date();
expiry.setTime(date.getTime()+(10*60*1000));
// Ten minutes
// Date()'s toGMTSting() method will format the date correctly for a cookie
document.cookie = "visited=yes; expires=" + expiry.toGMTString();
there is no way that you can set the life time coookie...i.e cookie with no expiration
Forever cookie: Possible if you re-write the cookie every time you read it, setting the expire date to some ridiculous date in the future eg: 10 yrs hence.
For that to not be forever you are assuming the web page will not be read for more than 10 years, in which case what's the point. You think we will still be using cookies in 10 yrs :-)
Plus a cookie longevity is only as long as the hardware its stored on. Will you be using the same hardware in 10 yrs?
Note: read cookie then immediately write same cookie I found was problematic on some computers (reason unknown). Fix was embed the write cookie in a timeout:
var x=getCookie('mycookie');
setTimeout('saveCookie("mycookie", x)',1000)
getCookie and saveCookie being functions you have to create in this example, and saveCookie function sets cookie life at 10 yrs
At the speed of technology evolution, that's 'forever' :-)