/** * @return string|\yii\web\Response 用户登录 */ public function actionLogin() { $model = new YiiUser(); $model->scenario = 'login'; if ($model->load(Yii::$app->request->post())) { if ($model->login()) { //查询未读消息 // $count=Msg::find()->andwhere(['tid'=>Yii::$app->user->getId(),'status'=>0])->count(); // $session=Yii::$app->session; // $session->set('msg',$count); return $this->redirect(['index/index']); } else { return $this->render('login', ['model' => $model]); } } return $this->render('login', ['model' => $model]); }