note 34856 added to function.setcookie
| From: | robg at snet dot net | Date: | Fri, 08 Aug 2003 17:32:25 +0000 |
| Subject: | note 34856 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53656@lists.php.net to get a copy of this message | ||
Here's a simple cookie example for you:
<?
/* Cookie Example.
Used to.. well, help me learn how to use cookies! */
if (!isset($_COOKIE['ainfo']))
{
$loginName = "Rob";
$loginPass = "rawb";
$loginWord = "special_me";
$ainfo = base64_encode($loginName.":".$loginPass.":".$loginWord);
setcookie ("ainfo", $ainfo, time() + 31536000);
echo "Cookie set. Try coming back next time, fat boi!";
}
else
{
$ainfo = base64_decode($_COOKIE['ainfo']);
$values = explode(":", $ainfo);
echo "Because you have cookies enabled, it looks like you are ". $values[0] .".
Your stored password is ". $values[1] ." and the special login word looks to be ".
$values[2] .". Isn't this right? Fat boy?";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34856
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34856&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34856&report=yes