PHP cookie 返回 "deleted" 作为值
PHP cookie returning "deleted" as value
我遇到了一个非常奇怪的问题,我很难弄清楚到底发生了什么。偶尔,我的 cookie returns 值 "deleted" 而不是它的正确值。如果 cookie 已过期,是否有任何网络浏览器会将 cookie 值变为 "deleted"?
我已经进行了大量 Google 搜索和 SO 搜索,但找不到类似的内容。
有人以前看过这个吗?
检查以确保您在调用 setcookie()
时设置了合理的到期时间,以确保您的 cookie 在使用期间不会过期。
From the php documentation (trimmed for important parts):
The time the cookie expires. This is a Unix timestamp so is in number
of seconds since the epoch. In other words, you'll most likely set
this with the time() function plus the number of seconds before you
want it to expire.
If set to 0, or omitted, the cookie will expire at the end of the
session (when the browser closes).
编辑
在 setcookie()
文档的下方,我发现了这个
Cookies must be deleted with the same parameters as they were set
with. If the value argument is an empty string, or FALSE, and all
other arguments match a previous call to setcookie, then the cookie
with the specified name will be deleted from the remote client. This
is internally achieved by setting value to 'deleted' and expiration
time to one year in past.
即您的 cookie 似乎在某处更新为空字符串或设置为 false。
我遇到了一个非常奇怪的问题,我很难弄清楚到底发生了什么。偶尔,我的 cookie returns 值 "deleted" 而不是它的正确值。如果 cookie 已过期,是否有任何网络浏览器会将 cookie 值变为 "deleted"?
我已经进行了大量 Google 搜索和 SO 搜索,但找不到类似的内容。
有人以前看过这个吗?
检查以确保您在调用 setcookie()
时设置了合理的到期时间,以确保您的 cookie 在使用期间不会过期。
From the php documentation (trimmed for important parts):
The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire.
If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).
编辑
在 setcookie()
文档的下方,我发现了这个
Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. This is internally achieved by setting value to 'deleted' and expiration time to one year in past.
即您的 cookie 似乎在某处更新为空字符串或设置为 false。