note 26199 added to function.setcookie
| From: | cookieHeader at inxil dot com | Date: | Tue, 22 Oct 2002 07:37:35 +0000 |
| Subject: | note 26199 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38403@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;
}
?>
--
http://www.php.net/manual/en/function.setcookie.php
http://master.php.net/manage/user-notes.php?action=edit+26199
http://master.php.net/manage/user-notes.php?action=delete+26199
http://master.php.net/manage/user-notes.php?action=reject+26199