用户不活动注销PHP [英] User Inactivity Logout PHP

查看:68
本文介绍了用户不活动注销PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的用户在闲置X分钟后自动注销.我还希望销毁所有会话.

I want my users to be logged out automatically after X minutes of inactivity. I also want to have all sessions destroyed.

这怎么办?我如何检查不活动状态,然后执行功能将其注销??

How can this be done? How can I check for inactivity then perform a function to log them out???

推荐答案

您也可以这样做:

$_SESSION['loginTime'] = time();

在每个页面上,当用户尝试导航并且他闲置了二十分钟时,您都可以像这样注销他:

On every page, and when the user is trying to navigate and he has been inactive for an twenty minutes you can log him out like this:

if($_SESSION['loginTime'] < time()+20*60){ logout(); }

这篇关于用户不活动注销PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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