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; secu
You could possibly set a cookie at an expiration date of a month or something and then reassign the cookie every time the user visits the website again
YOU JUST CAN'T. There's no exact code to use for setting a forever cookie but an old trick will do, like current time + 10 years
.
Just a note that any dates beyond January 2038
will doomed you for the cookies (32-bit int) will be deleted instantly. Wish for a miracle that that will be fixed in the near future. For 64-bit int, years around 2110
will be safe. As time goes by, software and hardware will change and may never adapt to older ones (the things we have now) so prepare the now for the future.
See Year 2038 problem
There is no syntax for what you want. Not setting expires causes the cookie to expire at the end of the session. The only option is to pick some arbitrarily large value. Be aware that some browsers have problems with dates past 2038 (when unix epoch time exceeds a 32-bit int).