简体   繁体   English

如何在用户不活动、注销或会话结束后清除数据库字段

[英]How to clear database field after user inactivity, logout or session end

I have a pivot table that is holding shopping cart type information like so我有一个像这样保存shopping cart类型信息的数据透视表在此处输入图片说明

I set processing= true while I am getting payment information and count them along with the registered ones so inventory does not get oversold by simultaneous purchases.我在获取付款信息​​时设置processing= true并将它们与registered信息一起计算,这样库存就不会因同时购买而超卖。 I can set processing=false if payment fails.如果付款失败,我可以设置processing=false

However in the cases where I don't get to finish payment processing...How do I reset processing to false when the user logs out, times out or ends their session or any other cases?但是,在我无法完成付款处理的情况下……当用户注销、超时或结束会话或任何其他情况时,我如何将processing重置为 false?

Depending on the user activity you could do all of the following:根据用户活动,您可以执行以下所有操作:

  1. Set SESSION variable and keep track of the time, if time expires then set the value to false设置 SESSION 变量并跟踪时间,如果时间到期,则将值设置为 false
  2. When user disconnects set value to false当用户断开连接时设置值为 false
  3. Depending on the database you are using you could add a timed event to set the value to false.根据您使用的数据库,您可以添加一个定时事件以将值设置为 false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM