note 26199 deleted from function.setcookie by sniper
| From: | sniper@php.net | Date: | Wed, 11 Dec 2002 07:15:38 +0000 |
| Subject: | note 26199 deleted from function.setcookie by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40720@lists.php.net to get a copy of this message | ||
Sorry, didn't paste the whole function:
<?
function cookieHeader($name, $value, $expDays=0, $expHours=0, $expMins=0, $expSecs=0, $manualExp=0)
{
/***********************************
Notes:
This is a really simple cookie function. Use expDays, expHours, expMins and expSecs
to set the expiration time. If it's too user-friendly, feel free to remove that feature.
It should handle all browsers, although I've only tested it on MSIE 6 (Win 2k, sp3). I
coded it with both Microsoft and Netscape's Specs in mind. If you find any errors, let
me know at: "cookieHeader .AT. inxil .DOT. com" (formatted to avoid spam).
***********************************/
$exp = ($expDays * 86400) + ($expHours * 3600) + ($expMins * 60) + $expSecs;
if (ereg("MSIE", getenv("HTTP_USER_AGENT"))) {
$time = mktime()+$exp;
$date = gmdate("D, d-M-Y H:i:s \G\M\T", ($time));
header("Set-Cookie: $name=$value; expires=$date; path=/;");
} else {
header("Set-Cookie: $name=$value; expires=" . time()+$exp . "; path=/;");
}
return true;
}
?>