note 53402 added to function.setcookie

From: Date: Tue, 31 May 2005 18:23:29 +0000
Subject: note 53402 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-89695@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53402 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53402&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53402&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53402&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53402&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53402&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53402&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89695) next »