If the expire parameter in setcookie() is set to 0, that means that the cookie will remain around as long as the browser is open.
What I wonder is, does browser closed mean that that particular browser window is closed, or the whole browser application is closed?
I have a script that sets a cookie, and when you have that cookie, you are allowed to view secretpageA.php. secretpageA.php has code in the beginning testing whether or not you have that particular cookie. I noticed that when I had successfully authorized and gooten my cookie and gone to secretpageA.php, if I opened a new browser window (keeping originally, authenticated page open) and went also to secretpageA.php, it told me I wasn't authorized and didn't have the cookie.
Is this how it is supposed to work or not?
Another quick cookie technicality question
Moderator: General Moderators
From PHP.net:
Or you can use sessions which will accomplish the same thing.
So just usetime()+60*60*24*30 will set the cookie to expire in 30 days. If not set, the cookie will expire at the end of the session (when the browser closes).
Code: Select all
<?php
setcookie ("TestCookie", $value);
?>