View Full Version : Using arrays in cookies?
06-28-2005, 05: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, 06:37 PM
Serialize the array.
06-28-2005, 06:44 PM
Could u give me an example? I'm not sure I'm understanding it correctly. :o
06-28-2005, 07:45 PM
$array = array('one', 'two' 'tacos' => 'three');
$somedata = serialize($array);
setcookie("cookiename", $somedata, time() + 15768000, '/', '.domain.com');
06-28-2005, 08:23 PM
Hmm.... but how would you use that to add to an exisiting cookie?
06-28-2005, 11:43 PM
I'm not sure, I don't work with cookies enough to tell you.
06-28-2005, 11:48 PM
Oh ok... thx 4 the help anyways! :thumbsup:
06-28-2005, 11:58 PM
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.