Session time out with Timer

我怕爱的太早我们不能终老 提交于 2019-12-08 03:43:47

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2232965/session-time-out-with-timer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!