views:

402

answers:

2

I want to time out the session with timer, I am implementing a ecommerce project, where I required when user add first product in the cart a timer will start and user add more products in the cart but user did not checkout the cart product within a specific time the cart session is timeout(cart empty). How can acchive this.

+4  A: 

Why would you do this? Instead of using session, store their cart details in the database. That way they can come back tomorrow ( or later that afternoon ) and check out.

Most of the big eCommerce sites never clear your cart. For the very good reason that users might actually come back to complete the process.

Chris Lively
@Chris Lively:for that purpose we have the wishlist.
Vijjendra
@vijjendra: The wishlist is for when the user might want to share the cart with other people in the hopes that they receive it as gifts. Or, for more long term storage of what they like. Take a look at newegg.com. They have one of the best shopping carts out there.
Chris Lively
@Chris: But my requirment is to timeout the cart after a specific time if user did not buy the products in that time.
Vijjendra
@Vijjendra: You could still do this if the cart information is stored in a database.
Chris Lively
+1  A: 

To actually answer the question: On server side, when a product is added to the cart save the date time stamp with it.

Whenever any page is loaded, check the date time stamp. If it is passed your acceptable point, simply delete the cart data.

Chris Lively