how to set this cookie to never expire [closed]

巧了我就是萌 提交于 2019-12-01 02:19:23

There is no way to set to never expire . It's not a javascript limitation, it's just not the part of the specification of the cookie http://www.faqs.org/rfcs/rfc2965.html.

You can set to a far date in the future. for example to set it for 20years from now call setCookie with 20*365 as exdays parameter as you setCookie function expect how many days before it expires. Like follows

setCookie('cookiename','cookie_val',20*365);

The variable exdays is how long it is until the cookie expires, just set that value to a couple of thousand days in your function call.

setCookie('cookiename', 'cookievalue', 10000); //expires in 10k days
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!