且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP会话超时回调?

更新时间:2023-12-04 19:30:04

您可以创建一个脚本,该脚本将以某种半固定的时间间隔运行(例如每 5 分钟一次,使用 crontab 作业),而不是检测 php 会话何时超时最有可能)将自动注销/执行对过去一小时(或任何您的超时值)未处于活动状态的任何人的清理.只需在您的用户表中添加一个lastseen".

Instead of detecting when the php session times out, you could create a script that will run at some semi regular interval (every 5 minutes say, using a crontab job most likely) that will log out/perform the clean up for anyone who hasn't been active in the last hour (or whatever your timeout value is) automatically. Just add a 'lastseen' to your user table.