cookies for shopping carts

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

Has anyone converted the script to use a cookie-based cart system instead of HOST or ADDR? I am having big problems with corporate customers that add an item to their cart, and see everything anyone else has added to the cart also. Most companies have some kind of shared hi-speed access, meaning that everyone shares the same IP address. As we know this means they share the same shopping basket too.

I really need a fix for this. Hope someone can help.

Todd

-- Todd Miller (todd@atrios.com), July 12, 1999

Answers

Hi,

There is a way of getting a unique order id number for every one that logs on your web site. Instead of "get_host" you would change it to "get_order_id". The problem with that method is you would have to place a hidden field on every web page to carry the "order_id" from page to page so as someone roams your web site they would not lose the order. Every page would have to check to see if you have a "order_id" if not make one. With a large site that is a lot of programing. If you read some of the early posts there is a reference to using this method. Not everyone uses cookies or Java Script so this might be the best way for all though not the easiest. I would be interested in any ideas anybody would have about using this method.

Jim

-- James L. Farmer (jim@team-blankets.com), July 15, 1999.


Jim - I liked your response and idea how to solve this problem. The only thing that I wonder about however is this: you said that it would require a lot of programming to send the users ip from page to page in the site. However, I found that my problems with AOL users loosing carts did not happen from page to page, but instead only happened when the user went to check out since the ip changed.

So, I put a hidden field in the form that says "check out". This form is called something like oldip. It is simply the $refer string that the user is currently using.

In the next section (the buy1) section, I have it read this hidden field and replace this current ip with the oldip that the user had when in non-secure mode. That way, the script reads their non- secure, pre-ip change shopping basket.

Lastly, I had the buy1 section add a hidden field with this same oldip number which is passed to the buy2 section of the script. That way the script processes the order with the old ip address prior to being in secure mode.

Using this logic, the users "initial" ip is passed through the two different secure server phases, and the s-mart is told to read the old cart with the original ip rather than the new "AOL secure" ip which was assigned and of course is empty.

One question though, using the REMOTE_ADDR, do you know if this ip number stays constant for users as they are browsing the web, or does it change over time?

Jim - You had a great idea and what appears to be a very simple fix to this issue. Good job!

-BP

-- BP (bppilot@aol.com), August 03, 1999.


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