note 4727 deleted from function.setcookie by sniper
| From: | sniper@php.net | Date: | Wed, 11 Dec 2002 06:46:54 +0000 |
| Subject: | note 4727 deleted from function.setcookie by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40703@lists.php.net to get a copy of this message | ||
If you want to set a complete array in only one cookie, use these functions:
<PRE>
function store_array_in_cookie($cookiename, $array2store) {
$tmpstring = serialize($array2store);
setcookie($cookiename, $tmpstring, time()+3600*5, "/", ".fbt.eitn.wau.nl");
unset($tmpstring);
}
function get_array_from_cookie($cookiename) {
$tmpstring = "global \$$cookiename";
eval($tmpstring);
unset($tmpstring);
if (isset(${$cookiename})) {
$tmparray=unserialize(stripslashes(${$cookiename}));
} else {
$tmparray = array();
}
return $tmparray;
}
</PRE>