/** * 登录 * @return string|\yii\web\Response */ public function actionLogin() { if (isset($_SESSION['admin_id'])) { return $this->goHome(); } if ($post = Yii::$app->request->post()) { $result = Admin::validateIdentify($post['username'], md5($post['password'])); if (!$result) { return $this->render('login', ['message' => '账号或密码错误']); } $_SESSION['admin_id'] = $result['id']; return $this->goBack(); } return $this->render('login', ['message' => '']); }