我使用 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/