Javascript Cookie with no expiration date

前端 未结 9 943

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         


        
9条回答
  •  旧时难觅i
    2020-11-27 14:03

    You can do as the example on Mozilla docs:

     document.cookie = "someCookieName=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
    

    P.S

    Of course, there will be an issue if humanity still uses your code on the first minute of year 10000 :)

提交回复
热议问题