Page 1 of 1

Cookies for shopping cart

Posted: Thu Sep 28, 2006 6:35 pm
by aceconcepts
Hi,

I have built a shopping cart using php. I am currently using session variables to store session_id() in order to identify the products in a users cart.

How can I use cookies to do the same thing?

Thanks.

Posted: Thu Sep 28, 2006 6:39 pm
by s.dot
I don't know why you'd want to. But, instead of setting the session variables, set the cookies.

Code: Select all

$_SESSION['prod_id'] = 11345614;
Would become...

Code: Select all

setcookie('prod_id',11345614,time()+x);
Of course you may wish to store things in arrays and serialize them to send to a single cookie.

Posted: Thu Sep 28, 2006 6:45 pm
by aceconcepts
Thanks.