php cookie 不过期,将Cookie设置为永不过期

最大值:2147483647

setcookie("CookieName", "CookieValue", 2147483647);

为避免整数溢出,时间戳记应设置为:

2^31 - 1 = 2147483647 = 2038-01-19 04:14:07

设置较高的值可能会导致旧版浏览器出现问题。

另请参阅有关cookie的RFC:

Max-Age=value

OPTIONAL.  The value of the Max-Age attribute is delta-seconds,

the lifetime of the cookie in seconds, a decimal non-negative

integer.  To handle cached cookies correctly, a client SHOULD

calculate the age of the cookie according to the age calculation

rules in the HTTP/1.1 specification [RFC2616].  When the age is

greater than delta-seconds seconds, the client SHOULD discard the

cookie.  A value of zero means the cookie SHOULD be discarded

immediately.

和RFC 2616、14.6年龄:

如果缓存收到的值大于它可以表示的最大正整数,或者如果任何年龄计算溢出,则它必须发送一个年龄值为2147483648(2 ^ 31)的Age标头。

http://www.faqs.org/rfcs/rfc2616.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值