Javascript Cookie with no expiration date

Jose Vega picture Jose Vega · Feb 10, 2009 · Viewed 179.7k times · Source

I would like to set up a cookie that never expires. Would that even be possible?

 document.cookie = "name=value; expires=date; path=path;domain=domain; secure";

I don't want to make the date really large, I am just wondering if there was a value for the expires parameter on the cookie that told it never to expire.

Thanks.

Answer

Paolo Bergantino picture Paolo Bergantino · Feb 10, 2009

Nope. That can't be done. The best 'way' of doing that is just making the expiration date be like 2100.