note 31464 deleted from function.setcookie by victor
| From: | victor@php.net | Date: | Sat, 27 Mar 2004 20:22:14 +0000 |
| Subject: | note 31464 deleted from function.setcookie by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67251@lists.php.net to get a copy of this message | ||
Note Submitter: janhouse00@hotpop.com
----
Bear in mind if you tried to store MULTIPLE STRING VALUE IN ONE COOKIE, you have to employ
addslashes prior to serializing them(sound odd but I just dunno why, myself has been spending tons
of time to figure it out).See the following scripts:
//makecookie.php
<?
$array[0]=addslashes("a");//it doesn't work if you remove the addslashes()
$array[1]=addslashes("b");
$array[2]=addslashes("c");
//print_r($array)
$s=serialize($array);
setcookie("cookies",$s,time()+86400);
?>
//test.php
<?
if(isset($cookies)){
$array=unserialize(stripslashes($cookies));
foreach($array as $i=>$cookie){
print"<br>$i => $cookie";
}
}
?>