1年的PHP setcookie将不起作用 [英] PHP setcookie for 1 Year will not work

查看:57
本文介绍了1年的PHP setcookie将不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一个PHP cookie设置为从用户登录之日起1年,并且我这样做的方式是:

I'm trying to set a PHP cookie to expire 1 Year from when the user logged in, and I'm doing it this way:

setcookie("myCookie",'exampleUserName',(365 * 24 * 60) ,'/');

问题是,当我在Chrome或Firefox中使用控制台查看Cookie时,显示Expires Chrome浏览器,2014年5月5日在Chrome中,而 Expires = Session 在Firefox中。

The problem is, when I view the cookie using the console in Chrome or Firefox, it show Expires Sun, 05, 2014 in Chrome and Expires = Session in Firefox.

任何其他网站,例如Google或stackoverflows Cookie都显示正确的到期日期。

Any other site like Google or stackoverflows cookies show the correct expiration date.

我如何设置此权限?

推荐答案

像这样...

setcookie("myCookie",'exampleUserName',time()+31556926 ,'/');// where 31556926 is total seconds for a year.

这篇关于1年的PHP setcookie将不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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