note 53402 rejected from function.setcookie by betz
| From: | betz@php.net | Date: | Sat, 11 Jun 2005 15:06:57 +0000 |
| Subject: | note 53402 rejected from function.setcookie by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90269@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at northstar dot k12 dot ak dot us
----
Cookies with a short expiration time ( < time() + 500 ) may not be set on all browsers. If you
run something like the below code:
<?php
for($i=0; $i < 600; $i += 30) {
setcookie('expiresIn'.$i, $i, time() + $i, '/', '.example.com',
0);
}
echo '<pre>'; print_r($_COOKIE); echo '</pre>';
?>
...Firefox will grab all $i > 0; Safari and IE5/Mac accept all $i > 300; IE6 accepts all $i
> 500.
But this isn't telling the whole story, either: working on a different application, I got IE6
to eat a cookie set with an expiration of time() + 221 -- and time() + 220 didn't work.
Workaround: if you are setting very short term cookies, set them to expire after at least time() +
501. Better still, rethink your application design to avoid short-term cookies.