Reputation: 634
I've found that if I set a cookie with no expiration value and then create another cookie, the first cookie seems to be destroyed. Is this because a new session is created or is it because it is another request?
I've resolved my 'problem' by actually setting an expiration time, but I'm just curious to know what is actually happening when the second cookie is being created.
setcookie('cookieA', 'stuff', null, '/');
setcookie('cookieB', 'stuff', time() + 1200, '/');
Upvotes: 0
Views: 100
Reputation: 355
$expire_time has it's own role in function setcookie and if it's less than now the cookie is deleted. There's no way not to set an expiration time or set it to null. It's simply a specification of cookies to achieve an expiration time (http://www.faqs.org/rfcs/rfc2965.html).
If you want the cookie to last forever, just set it to enormously huge number
Good Luck. :)
Upvotes: 1