note 72960 deleted from function.setcookie by googleguy
| From: | googleguy@php.net | Date: | Tue, 15 Jan 2013 05:12:20 +0000 |
| Subject: | note 72960 deleted from function.setcookie by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193070@lists.php.net to get a copy of this message | ||
Note Submitter: brian dot powell at insetsolutions dot com
----
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" );
}
?>