On Fri, 29 Aug 2003 13:51:55 -0500, in message
<fhN3b.300494$uu5.64849@sccrnsc04>, the AI program named "Alexander Ross"
<al******@bleen.net> randomly printed:
I want a cookie that can have about 5 values. I was told to do something
like this:
to set the cookie the first time:
setcookie("questions[]",$_POST['questionid'],time()+60*60*24,"/","",0);
then to add valus to this cookie later:
setcookie("questions[]",$_POST['questionid']);
the problem is that when I do this, the cookie's first value is just
getting replaced over and over again.
How do I handle a cookie so I can just keep pushing values on to it n
times so that at the end I have an array with n values??
--
Alexander Ross
al******@bleen.net
You could store the values in an array. Then you would
serialize() and base64_encode() it to put it
into a cookie.
To get the array back, base64_decode() it and
unserialize() it.
Then add whatever items you want to the array
and do it all over again.
BTW: It's probably not a good idea to put too much
junk into the HTTP header; it might reduce efficiency.
If you have an array with 1000 elements, I advise against
putting it into a cookie because it would slow things
down.
Just use a session variable. Putting an array into a
session is just too easy.