Shopping Cart ID - IP Address vs. Cookies?

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

I have been using the S-mart shopping cart for about 8 months and have run into problems with the shopping cart. When customers from certain internet providers try to place orders, they sometimes lose their shopping cart. I know that this problem has to do with using the IP Address as the cart ID. I have heard from many people that cookies are better than using the IP Address or generating unique IDs for shopping carts. I have read messages from this board where people disagree that cookies are the best option, but if you go to amazon.com, cdnow.com and many other large internet stores, you will find that they use cookies. Obviously cookies are the most popular, and apparently the best way to keep a shopping cart. My question is that if anyone has been able to modify the script so it uses cookies instead of the IP address to keep track of customers' shopping carts?

-- Jeremy Smith (pancakepan@usa.net), January 23, 1999

Answers

Cookies stores information at the remote site. IP will only be capture for use in the server site. So both will have advantages and diadvantages. But the following is a suggested solution using the IP method.

Find the following section in the SMART.CGI file:

# Get the hostname, for file reference sub get_host { $host = $ENV{'REMOTE_HOST'}; $reffile = "$tmpdir$delim$storename-$host"; }

Replace with the following lines:

# Get the hostname, for file reference sub get_host { $host = $ENV{'REMOTE_HOST'}; $p_id = ($$ % 10000); $reffile = "$tmpdir$delim$storename-$host-$p_id"; }

-- God bless!

-- Patrick Chan (patrickccf@hotmail.com), February 14, 2000.


I have implemented cookies with my cart. If you are interested to know more, email me at patrickccf@hotmail.com.

--
God bless!

-- Patrick Chan (patrickccf@hotmail.com), March 20, 2000.


Moderation questions? read the FAQ