Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-28-2005, 05:54 PM   PM User | #1
cyphix
Regular Coder

 
Join Date: Apr 2004
Posts: 682
Thanks: 24
Thanked 1 Time in 1 Post
cyphix is an unknown quantity at this point
Using arrays in cookies?

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..

PHP Code:
setcookie("cookiename[]"somedatatime() + 15768000'/''.domain.com'); 
Any ideas??

Thanks!
cyphix is offline   Reply With Quote
Old 06-28-2005, 06:37 PM   PM User | #2
Kurashu
Regular Coder

 
Join Date: Aug 2004
Location: The US of A
Posts: 767
Thanks: 1
Thanked 0 Times in 0 Posts
Kurashu is an unknown quantity at this point
Serialize the array.

http://www.php.net/serialize
Kurashu is offline   Reply With Quote
Old 06-28-2005, 06:44 PM   PM User | #3
cyphix
Regular Coder

 
Join Date: Apr 2004
Posts: 682
Thanks: 24
Thanked 1 Time in 1 Post
cyphix is an unknown quantity at this point
Could u give me an example? I'm not sure I'm understanding it correctly.
cyphix is offline   Reply With Quote
Old 06-28-2005, 07:45 PM   PM User | #4
Kurashu
Regular Coder

 
Join Date: Aug 2004
Location: The US of A
Posts: 767
Thanks: 1
Thanked 0 Times in 0 Posts
Kurashu is an unknown quantity at this point
PHP Code:
$array = array('one''two' 'tacos' => 'three');
$somedata serialize($array);
setcookie("cookiename"$somedatatime() + 15768000'/''.domain.com'); 
Kurashu is offline   Reply With Quote
Old 06-28-2005, 08:23 PM   PM User | #5
cyphix
Regular Coder

 
Join Date: Apr 2004
Posts: 682
Thanks: 24
Thanked 1 Time in 1 Post
cyphix is an unknown quantity at this point
Hmm.... but how would you use that to add to an exisiting cookie?
cyphix is offline   Reply With Quote
Old 06-28-2005, 11:43 PM   PM User | #6
Kurashu
Regular Coder

 
Join Date: Aug 2004
Location: The US of A
Posts: 767
Thanks: 1
Thanked 0 Times in 0 Posts
Kurashu is an unknown quantity at this point
I'm not sure, I don't work with cookies enough to tell you.
Kurashu is offline   Reply With Quote
Old 06-28-2005, 11:48 PM   PM User | #7
cyphix
Regular Coder

 
Join Date: Apr 2004
Posts: 682
Thanks: 24
Thanked 1 Time in 1 Post
cyphix is an unknown quantity at this point
Oh ok... thx 4 the help anyways!
cyphix is offline   Reply With Quote
Old 06-28-2005, 11:58 PM   PM User | #8
marek_mar
Sensei


 
Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
marek_mar is on a distinguished road
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.
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.

Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.
marek_mar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:06 AM.


Advertisement
Log in to turn off these ads.