<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## [PHP交流群:494826865(點擊群號立即加群)](https://jq.qq.com/?_wv=1027&k=50Qy5h6) # 管理員登錄補充 > 到這里管理員的登錄功能就完成了,但是還有一些細節上需要做一下優化。 1. 管理員已登錄時,自動跳過登錄頁面 2. 在后臺操作時,如果登錄超時的處理。 ##### 一、自動跳過登錄頁面 >[success] 在進入登錄頁面時,需要判斷管理員是否登錄 控制器層:`Admin/LoginController.php` ~~~ ? ?/** ? ? * 加載登頁面 ? ? * @RequestMapping(route="login", method=RequestMethod::GET) ? ? */ ? ?public function index() ? { ? ? ? ?//判斷是否登錄 ? ? ? ?if($this->loginlogic->checkLoginStatus()){ ? ? ? ? ? ?return context()->getResponse()->redirect("/admin"); ? ? ? } ? ? ? ?return view("admin/login/login"); ? } ~~~ 邏輯層:`Modle/Logic/LoginLogic.php` 新增:`checkLoginStatus`方法,用來檢測管理員的登錄狀態 ~~~ ? ?/** ? ? * 判斷用戶登錄狀態 ? ? */ ? ?public function checkLoginStatus(){ ? ? ? ?if(HttpSession::current()->has("username") && HttpSession::current()->has("userid")){ ? ? ? ? ? return true; ? ? ? } ? ? ? ?return false; ? } ~~~ ##### 二、登錄超時的處理 >[success] 判斷是否登錄超時,所有的后臺操作都進行驗證檢測,所以在這里直接在中間件中進行驗證。 在`Http/Middleware/CheckLoginMiddleware.php`添加檢則代碼 ~~~ ? ?public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface ? { ? ? ? ?if(HttpSession::current()->has("username") && HttpSession::current()->has("userid")){ ? ? ? ? ? ?// before request handle ? ? ? ? ? ?return $handler->handle($request); ? ? ? } ? ? ? ?//判斷請求類型 ? ? ? ?if($request->isAjax()){ ? ? ? ? ? ?throw new HttpExecption("登錄超時",3); ? ? ? } ? ? ? ?return context()->getResponse()->redirect("/admin/login"); ? ? ? ? ?// after request handle ? } ~~~ >[success] 添加過之后,即可進行檢測,前提是控制器要經過中間件。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看