note 26490 deleted from function.setcookie by didou
| From: | didou@php.net | Date: | Sat, 31 May 2003 15:00:53 +0000 |
| Subject: | note 26490 deleted from function.setcookie by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-49490@lists.php.net to get a copy of this message | ||
Note Submitter: MadLogic@Paradise.net.nz
----
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!