note 26490 added to function.setcookie
| From: | MadLogic at Paradise dot net dot nz | Date: | Fri, 01 Nov 2002 10:07:45 +0000 |
| Subject: | note 26490 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38865@lists.php.net to get a copy of this message | ||
Heres a simple and tidy way of using the setcookie feature!
<?
// Check to see if chocolate chip cookie actually exists.
if (isset($_COOKIE["ChocolateChip"])) {
// Grab the value from cookie.
$value = $_COOKIE["ChocolateChip"];
// Print the cookie value.
print "$value";
// If chocolate chip cookie doesn't exist ...
} else {
// Set cookie with a value.
setcookie ("ChocolateChip","Yummmmmy!");
// Redirect back to this page.
header("Location: cookies.php");
}
?>
The above code would output:
Yummmmmy!
--
http://www.php.net/manual/en/function.setcookie.php
http://master.php.net/manage/user-notes.php?action=edit+26490
http://master.php.net/manage/user-notes.php?action=delete+26490
http://master.php.net/manage/user-notes.php?action=reject+26490