什么是PHP的cookie的默认生命周期?

时间:2013-02-06 08:52:12

标签: php cookies

如果我没有在cookie中设置任何生命周期,那么cookie中的默认生命周期是什么时候?

例如

setcookie("cookiename", $value);

5 个答案:

答案 0 :(得分:5)

当您通过PHP创建cookie时,默认值为0,来自手册:

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

否则,您可以将cookie生命周期设置为秒,作为第三个参数:

http://www.php.net/manual/en/function.setcookie.php

答案 1 :(得分:1)

来自documentation

  

<强>到期

     

如果设置为0或省略,则cookie将在会话结束时(浏览器关闭时)到期。

答案 2 :(得分:1)

cookies示例

如果未设置参数,则cookie将在会话结束时(浏览器关闭时)到期..

答案 3 :(得分:1)

When you create a cookie via PHP Default Value is 0

If set to 0, or omitted, the cookie will expire at end of the session 
ie when the browser  closes

答案 4 :(得分:0)

如果设置为0或省略,则cookie将在会话结束时(浏览器关闭时)到期。

http://php.net/manual/en/function.setcookie.php

相关问题