# 如何让PHP生成的COOKIE随浏览器关闭而失效？

- Link: https://www.xuepaijie.com/html/skill/devops/586.html
- Published: 2016-03-11T21:50:01+08:00
- Author: Admin

当设置cookie的过期时间$expire 为0时, 表示cookie的保存时间与浏览器进程一致，在浏览
器进程未关闭状态，cookie均会存在，浏览器关闭后cookie会消失，php 手册上的解释为

“If set to 0, or omitted, the cookie will expire at the end of the session (when
the browser closes). ”

解释意思为：

当设置cookie过期时间为0或者忽略不设置的情况下，cookie将会在session过期后过期（即
浏览器关闭后cookie过期）。
