解决后台管理系统的管理员15分钟内未做任何操作,长时间登录不退出问题
2022-10-28 15:19:56
178
{{single.collect_count}}

http://blog.51cto.com/gaoshan2016

//检测用户停留网站15分钟后无任何操作,并执行登出

    public function checkAdminSession() { 

       $nowtime = time(); 

       $s_time = $_SESSION['last_access'];

       if($_SESSION['last_access'] && $nowtime-$_SESSION['last_access'] > 900){

           unset($_SESSION);

           session_destroy();

           header("Location:".U("admin/public/login"));

        }else{

            $_SESSION['last_access'] = $nowtime;

        }

    }

将此方法在构造函数__construct()中调用即可。

 

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}