note 31499 deleted from function.setcookie by victor

From: Date: Sat, 27 Mar 2004 20:22:07 +0000
Subject: note 31499 deleted from function.setcookie by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-67250@lists.php.net to get a copy of this message
Note Submitter: ---- > 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). This code (from above): <? $array[0]=addslashes("a");//it doesn't work if you remove the addslashes() $array[1]=addslashes("b"); $array[2]=addslashes("c"); echo serialize($array); ?> Returns: a:3:{i:0;s:1:"a";i:1;s:1:"b";i:2;s:1:"c";} ... and so does the same code without addslashes(): <? $array[0]="a"; $array[1]="b"; $array[2]="c"; echo serialize($array); ?> Returns: a:3:{i:0;s:1:"a";i:1;s:1:"b";i:2;s:1:"c";} Possibly you need addslashes() if your values contain ' or " but I never needed it (if "magic quotes" is on). In such a case you could just use addslashes() on the serialized string.

« previous php.notes (#67250) next »