Tutorial :Session time out with Timer


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.


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.


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »