login(); print_r($userInfo); // 成功则跳转. if ($userInfo['code'] === 1) { return $this->redirect('Admin/Index/index'); // 失败则返回错误信息. } else { $msg = $userInfo['msg']; } } catch (Exception $e) { Log::write($e->getMessage(), 'error'); } } $this->assign([ 'errorMsg' => $msg, ]); return $this->fetch(); }//end login() /** * 退出登陆 * * @access public * @return string */ public function logout() { try { // 退出登陆. $userInfo = model('Admin')->logout(); // 成功. if ($userInfo['code'] === 1) { return $this->redirect('Admin/Login/login'); } } catch (Exception $e) { Log::write($e->getMessage(), 'error'); } }//end logout() }