php - setcookie with expire=0 在浏览器关闭后不会过期

标签 php google-chrome cookies

我使用 setcookie 制作一个 expire=0 的 cookie。从 PHP 文档中, ( link )

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. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

我的 php 代码:

setcookie('option', 'yes', 0, '/');

但是,当我关闭并重新打开浏览器(chrome 但不是 firefox)时,cookie 仍然没有过期(仍然可以访问)。

如何让cookie在浏览器关闭时过期?

最佳答案

哦...这是因为我在 chrome://chrome/settings/中激活了“从我离开的地方继续”。

参见 here

关于php - setcookie with expire=0 在浏览器关闭后不会过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17124044/

相关文章:

c# - 数据库的跨平台加密

javascript - 获取有关触发特定事件的元素的信息的标准方法

javascript - 如何从 sessionStorage 中存储的 JSON 值中检索特定对象?

ajax - 通过 CORS 请求设置 cookie

php - Wordpress - 二十四主题 - 将特色内容 slider 移动到内容区域

php - 无法从 Apache 内部连接 ​​Net_SSH2

javascript - Google Chrome 扩展的 onBrowserClose 事件?

javascript - d3 中的渲染性能

go - Cookie 不会在同一域的不同页面之间持续存在

php - 逐步通过 php 文件流式传输 mp4