Forum Moderators: coopster

Message Too Old, No Replies

setting cookies.

         

JoJoJohnson

3:46 pm on Feb 20, 2005 (gmt 0)

10+ Year Member



I am trying to set 3 cookies on my web site using the following code

<?PHP
setcookie("user_type", $user_type, time()+31536000);
setcookie("first_name", $first_name, time()+31536000);
setcookie("user_ID", $user_ID, time()+31536000);
?>

On IE this is fine, but with firefox and netscape it is only setting the first_name cookie.

can anyone help?

dreamcatcher

4:28 pm on Feb 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi JoJoJohnson,

Have you echoed your variables to see if they all hold values?

JoJoJohnson

4:48 pm on Feb 20, 2005 (gmt 0)

10+ Year Member



i feel such a fool.

i overlooked that problem becuase I thought that was too simple a thing to have gone wrong.

but yeah that was the problem.

thanks.

dreamcatcher

5:57 pm on Feb 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hee hee, don`t worry, we`ve all been there. :)

hakre

6:05 pm on Feb 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



one more tipp: think about setting only one cookie containing all the data instead of setting 3 cookies. that will save space in memory of your users browser. cookie space is often limited.

JoJoJohnson

4:19 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



thanks,

how would i go about saving it all into one cookie?

Elijah

4:26 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



You could create an array of the values you want to store. Then you could call serialize() on the array and store the returned string in a cookie. Then to read the the values back from the cookie into an array, you would just call unserialize() on the string that is stored in the cookie.