Bladeren bron

更新 'application/admin/controller/Base.php'

Me 5 jaren geleden
bovenliggende
commit
d376b38e33
1 gewijzigde bestanden met toevoegingen van 9 en 2 verwijderingen
  1. 9 2
      application/admin/controller/Base.php

+ 9 - 2
application/admin/controller/Base.php

@@ -1,15 +1,17 @@
 <?php
 namespace app\admin\controller;
 use think\Controller;
-
+use app\admin\controller\Login;
 use think\Request;
 
 class Base extends Controller//公共控制器
 { 
-    protected $current_action;
 
     public function _initialize()
     {
+       if(time()-session('tuot')>=0){// 当前时间 - 设置过期时间>=0 就说明登录过期
+           $this->tout();//退出登录,跳转到登陆界面
+       }
       //判断有无uname或者id的session,如果没有,跳转到登陆界面
         if(!session('admin_auth.uname')||!session('admin_auth.id')){
              $this->redirect(url('/lst'));//url("/lst"):为后台登录地址,设置路由进行替换的(在route.php中查看)
@@ -28,6 +30,11 @@ class Base extends Controller//公共控制器
         
 
     }
+  
+   public function tout(){//登录过期调用退出登录,跳转到登录界面
+        $times = new Login();
+        $times->logout();
+    }