首页> 实战笔录 >PHP开发笔记 >ThinkPHP ThinkPHP
PHP/ThinkPHP实现用户一段时间没有操作,系统自动退出
作者:小萝卜 2022-11-09 【 PHP TP5 TP3.2 jquery TP6 】 浏览 2165
简介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)
相关文章
- ThinkPHP3.2和5.0的区别
- TP6报错:Non-static method think\Request::controller() should not be called statically
- ThinkPHP集成QueryList和PhantomJS插件实现采集动态加载的页面的数据
- tp5实现文件下载,并对下载的文件重命名
- TP3.2模板内使用U方法详细介绍
- Thinkphp框架中三元运算符的使用方法
- TP5/TP6按驼峰命名了控制器和方法,运行时报错找不到模板文件
- phpQuery介绍及简单的使用
- TP6/ThinkPHP6 多应用模式域名串模块的问题
- TP6阿里云OSS上传报SSL certificate problem:unable to get local issuer certificate