View Full Version : Using arrays in cookies?
06-28-2005, 06:54 PM
Is there a way to successfully use arrays in cookies? Like I wanna add to the cookie but it doesn't seem to work..
Tried doing this but it doesn't seem to work..
setcookie("cookiename", somedata, time() + 15768000, '/', '.domain.com');
Any ideas?? :confused:
06-28-2005, 07:37 PM
Serialize the array.
06-28-2005, 07:44 PM
Could u give me an example? I'm not sure I'm understanding it correctly. :o
06-28-2005, 08:45 PM
$array = array('one', 'two' 'tacos' => 'three');
$somedata = serialize($array);
setcookie("cookiename", $somedata, time() + 15768000, '/', '.domain.com');
06-28-2005, 09:23 PM
Hmm.... but how would you use that to add to an exisiting cookie?
06-29-2005, 12:43 AM
I'm not sure, I don't work with cookies enough to tell you.
06-29-2005, 12:48 AM
Oh ok... thx 4 the help anyways! :thumbsup:
06-29-2005, 12:58 AM
You should just watch out for one thing. The serialized arrays carry their types of values unlike _POST/_GET (where everything is a string) so you might want to check if the types are correct.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.