[SOLVED] shopping cart cookies
Posted: Mon Oct 18, 2004 10:26 pm
feyd | Help us, help you. Please use
This section of the code is located at the top of my cart.php file where rest of the cart operations (add, delete, update) happen.
I think I set the cookies before any html tags but it still doesn't work.
Any suggestions?
feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Can someone please help me?
I have written the code for a very basic shopping cart. It was working fine but as soon as I deleted the cookies of my browser and tried to run the code in a new browser window my shopping cart stopped working properly. I could only add one item at a time and it wouldn't display the items I added previously and also I wasn't able to update the quantity.
This is the code for how I set the session cookies:Code: Select all
if(!isset($HTTP_COOKIE_VARS['cart_id'])) {
$cart_id = md5(uniqid(rand()));
setcookie("cart_id", $cart_id, time() + 14400);
} else {
$cart_id = $HTTP_COOKIE_VARS['cart_id'];
}I think I set the cookies before any html tags but it still doesn't work.
Any suggestions?
feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]