首页> 实战笔录 >PHP开发笔记 >ThinkPHP ThinkPHP
PHP/ThinkPHP实现用户一段时间没有操作,系统自动退出
作者:小萝卜 2022-11-09 【 PHP TP5 TP3.2 jquery TP6 】 浏览 2651
简介PHP/ThinkPHP实现用户一段时间没有操作,系统自动退出代码分享
前端代码:
var maxTime = 30*60; // seconds
var time = maxTime;
$(document).on('keydown mousemove mousedown', function(e){
time = maxTime; // reset
});
var intervalId = setInterval(function(){
time--;
if(time <= 0) {
ShowInvalidLoginMessage();
clearInterval(intervalId);
}
}, 1000)
function ShowInvalidLoginMessage(){
// 清除cookie
// 提示用户
// 该干嘛干嘛
alert('您已超过30分钟无任何操作已自动退出!');
location.href="/Admin/Login/tuichu";
}
后端代码:
//一段时间不操作自动退出
public function tuichu(){
session(null);
$this->redirect('Admin/Login/index');
}
很赞哦! (1)
相关文章
- TP5 使用QueryList 常见问题
- TP5 模型事务操作
- TP5实现微信H5支付
- TP6/Mysql源生查询当前月每天的数据统计
- tp5/tp6新增app版本跟新接口
- tp5使用jwt生成token,做api的用户认证
- url的301跳转 tp3.2 tp5.0实现方式
- thinkphp utf8中文排序,根据汉字拼音首字母排序
- TP6定义常量报错:Use of undefined constant CONTROLLER_NAME - assumed 'CONTROLLER_NAME'
- TP6使用Jwt验证token时报错Cannot pass parameter 3 by reference
