I am storing the items of shopping cart into a session array, but since the product ids and quantity is being stored on the client side , I can't perform a check on the quantity of items when a customer wants to add an item whose available quantity is already added to other customers carts.
So I have added a column called added_to_cart
in my Products
table which increments when a product/item is added to a customers session cart.
Now I want to time out the session when there's no activity by the customer for an hour and decrement the added_to_cart
by checking what's stored in the inactive(to be timed out)php session
Products
-----------------------------------------
: p_id : available_qty : added_to_cart :
-----------------------------------------
: p-123 : 57 : 3 :
-----------------------------------------
: p-287 : 32 : 8 :
-----------------------------------------
1.Is it possible to do it when the customer doesn't visit the site ever after(i.e without calling the session_start()).If so how?.
2.Is it the right proposed solution?How do they do it in bigger online stored like amazon and ebay?
You should do the FINAL quantity check when order is placed/submitted, not when added to cart. Think what happens, if somebody adds all products in your system to cart (just for fun).. your eCommerce shop would be sold out :)
So should be like:
There is also lot of well maid, free eCommerce softwares available like: Magento (http://magento.com/)
TIMED SESSIONS:
But if you really want to do the session thing, you can:
Keep in mind that the sessions (reserved products related) should then be quite short (like 30 minutes?).