首页 > 其他 > 详细

cookie 设置报错 setcookie() expects parameter 3 to be integer, float given in...

时间:2019-12-03 23:59:22      阅读:255      评论:0      收藏:0      [点我收藏+]

使用 setcookie 函数设置 cookie 报错,报错信息为:

setcookie() expects parameter 3 to be integer, float given in...

 

错误代码

setcookie("user_name", $username, time()+3153600000, "/"); 

 

一开始以为是 https 的问题,后来修改为 http only 也不行,最后发现原来是设置 cookie 过期的时间戳太大,从报错信息看也是显示第三个参数错误,

试着把时间戳调小一点..居然没报错了,看来确实是时间戳的问题。
突然想起,时间戳的最大值是到 2038年 (32位),一查,果然超了。
再看看配置文件,写的是66 * 265 * 86400,居然是66年过期,已经超过了PHP的setcookie函数处理范围
把配置调小,错误立马解决

cookie 设置报错 setcookie() expects parameter 3 to be integer, float given in...

原文:https://www.cnblogs.com/ryanzheng/p/11980217.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!