没有过期日期的 Javascript Cookie [英] Javascript Cookie with no expiration date

查看:34
本文介绍了没有过期日期的 Javascript Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个永不过期的 cookie.这可能吗?

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";

我不想让日期变得非常大,我只是想知道 cookie 上的 expires 参数是否有一个值告诉它永不过期.

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.

谢谢.

推荐答案

不.那是做不到的.最好的方法"就是让到期日期像 2100 年一样.

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

这篇关于没有过期日期的 Javascript Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆