【问题标题】:setcookie with expire=0 does not expire after the browser closesexpire=0 的 setcookie 不会在浏览器关闭后过期
【发布时间】:2013-06-12 00:30:32
【问题描述】:

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

cookie 过期的时间。这是一个 Unix 时间戳,因此是自纪元以来的秒数。换句话说,您很可能会使用 time() 函数加上您希望它过期之前的秒数来设置它。或者你可以使用 mktime()。 time()+60*60*24*30 将设置 cookie 在 30 天内过期。 如果设置为 0 或省略,cookie 将在会话结束时(浏览器关闭时)过期。

我的php代码:

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

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

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

【问题讨论】:

    标签: php google-chrome cookies


    【解决方案1】:

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

    here

    【讨论】:

      猜你喜欢
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 2012-01-21
      • 2014-09-26
      • 2016-12-07
      • 2016-09-23
      • 2018-06-19
      • 1970-01-01
      相关资源
      最近更新 更多