Skip to content
Advertisement

What is default life time of cookies in PHP? [closed]

If I have not set any life time in cookies then what is the default life time in cookie?

for e.g

setcookie("cookiename", $value);

Advertisement

Answer

When you create a cookie via PHP, the default value for its expiration date is 0, which means that the cookie expires when you close the tab from the manual:

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

Otherwise, you can set the cookies lifetime in seconds as the third parameter:

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

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement