note 26198 deleted from function.setcookie by betz

From: Date: Tue, 22 Oct 2002 09:51:23 +0000
Subject: note 26198 deleted from function.setcookie by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-38408@lists.php.net to get a copy of this message
I just wrote this code. It should work. <? 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). ***********************************/ 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; } ?>

« previous php.notes (#38408) next »