Reputation: 25559
On domain 1, I have a form that posts to domain 2
<form method="post" action="http://domain2.com/result.php">
The script result.php on domain 2 sets a cookie on domain 2 that is supposed to last until the year 2038.
setcookie('test', 'val', 2147485540, '/', '.domain2.com', false);
The cookie is being stored, but on Chrome, the expiration is set to "When I close my browser" (in other words, 0). On Firefox the expiration is set correctly.
Is there any way around this or is this a Chrome security setting regarding cross-domain posting that I'll just have to live with?
Upvotes: 0
Views: 884
Reputation: 281
It has to do with the expiration, not the domain. You are using 2147485540
which is equivalent to Tue, 19 Jan 2038 03:45:40
Some browsers have trouble with dates beyond 03:14:07 UTC on Tuesday, 19 January 2038.
This will work:
setcookie('test', 'val', gmmktime(3, 14, 7, 1, 19, 2038), '/', '.domain2.com', false);
This won't:
setcookie('test', 'val', gmmktime(3, 14, 8, 1, 19, 2038), '/', '.domain2.com', false);
Upvotes: 2