AmitG
AmitG

Reputation: 609

How to maintain client session for shopping cart even when user has not logged in

I have a question, I looked on google and other threads on Stackoverflow as well. But did not get any accurate answer. Please help me redirect to ..

  1. I use Amazon.com (just an example, could be any other e-commerse site) and keep on adding my items in wishlist. (While I have not yet logged in)
  2. I close browser and system and then I came next day or may be after 10 days or longer time.
  3. I can see the Wish list is there as it was.

  4. Is Amazon maintaining Client side cookie on client side only to save data? But data will be too big and not reliable for accuracy.

  5. Are they using a GUID on client side (for 1 year) and they send it to server where they already have Data base sessionId mapping with this in their DB?
  6. when we once login to amazon, my wishlist and cart is always there. means they might have beed updated with client cookie.

I was asked this in Interview as design/architect question and I got confused. So wanted to clear it from you friends.

Upvotes: 2

Views: 2196

Answers (1)

Raj
Raj

Reputation: 527

Ideally you need HTML5 and make use of Local Storage (http://dev.w3.org/html5/webstorage/)

A key value pair can be saved like below:

localStorage.setItem("Basket", {"item":"Product 1","price":100.50,"qty":2,"currency":USD});

Upvotes: 1

Related Questions