note 72960 added to function.setcookie
| From: | brian dot powell at insetsolutions dot com | Date: | Tue, 06 Feb 2007 02:35:33 +0000 |
| Subject: | note 72960 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122902@lists.php.net to get a copy of this message | ||
Here is problem I ran into during a recent bout with IE7 and cookies. IE will not delete a cookie
value if the time is set to the past. It will hold the value no matter how far in the past you set
the "expire" value. IE7 is the only browser I have had problems with - so here is the
solution I came up with.
<?PHP
//check to see how to set the cookie
$Browsertype = $_SERVER['HTTP_USER_AGENT'];
$Parts = explode(" ",$Browsertype);
$MSIE = array_search("MSIE",$Parts);
if($MSIE)
{
setcookie("name", "", time()+20000);
}
else
{
setcookie("name", "", time()-20000, "/", ".domain.com" );
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 70.130.163.106
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- https://master.php.net/note/edit/72960
Del: integrated -- https://master.php.net/note/delete/72960/integrated
Del: useless -- https://master.php.net/note/delete/72960/useless
Del: bad code -- https://master.php.net/note/delete/72960/bad+code
Del: spam -- https://master.php.net/note/delete/72960/spam
Del: non-english -- https://master.php.net/note/delete/72960/non-english
Del: in docs -- https://master.php.net/note/delete/72960/in+docs
Del: other reasons-- https://master.php.net/note/delete/72960
Reject -- https://master.php.net/note/reject/72960
Search -- https://master.php.net/manage/user-notes.php