PHP会话超时回调? [英] PHP session timeout callback?

查看:149
本文介绍了PHP会话超时回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行一个PHP + APACHE + CENTOS Linux的组合。

I'm running a PHP + APACHE + CENTOS Linux combination.

我实现了一个登录&安培;注销在网站上。

I have implemented a login & logout on the website.

我的问题是,我怎么能知道什么时候PHP会话已超时(用户已关闭他的浏览器不记录出)?

My question is, how can I know when the php session has timed-out (User has closed his browser without logging-out)?

究其原因,我想执行一些清理和/或数据库更新(调用另一个PHP)当用户做任何操作:
(1)登出或(2)超时

The reason is, I want perform some cleanups and/or database updates (calling another PHP) when the user has done any of the following: (1) LOGGED-OUT or (2) TIMED-OUT

我的猜测是,我将不得不作出使用Apache / Linux的,对吧?

My guess is that I would have to make use of Apache/Linux, right?

推荐答案

除了使用crontab的工作,当检测PHP会话超时,你可以创建一个脚本,将在一些半固定时间间隔(每5分钟说运行最有可能的),将注销/执行清理的人谁没有在最后时刻被激活(或任何你超时值)自动。只需添加一个'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.

这篇关于PHP会话超时回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆