定时器会话超时
我想用计时器使会话超时, 我正在实现一个电子商务项目,当用户在购物车中添加第一个产品时,我需要启动计时器,并且用户在购物车中添加更多产品,但用户没有在特定时间内结帐购物车产品,购物车会话超时(购物车为空) )。 怎样才能达到这个目的呢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.
实际回答这个问题:
在服务器端,当产品添加到购物车时,请保存日期时间戳。
每当加载任何页面时,请检查日期时间戳。如果超过了您的可接受点,只需删除购物车数据即可。
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.