Create cookie this way:
<?php
setcookie ("CookieName","Value");
//redirect to a main screen
header("Location: main.php");
?>
In the file main.php, test for the value:
<?php
if ($_COOKIE['CookieName'])
{
echo $_COOKIE['CookieName'];
}
else
{
echo "cookie could not be set";
}
?>
PHP: Cookies
- Details
- Written by: Marek
- Category: Programming
- Hits: 2709