bobysky
- bobysky 提出了问题域名地址区分商城多店铺实现,求助
- bobysky 提出了问题通过域名,区分多店铺的问题
- bobysky 评论了教程 Yii 2.0 用户登陆
为什么我登录成功后,
Yii::$app->user->isGuest
值还是true? //isGuest从这获取 public function getIsGuest() { return $this->getIdentity() === null; } //这个方法调用的$this->_identity,即是你上面那个方法设定的 //你上面那个方法也是传得一个参数进去的,它是一个实例于IdentityInterface接口的对像,具体实现自已写 //它里面有各种获取_identity的方法,比如findIdentity(),,, public function getIdentity($autoRenew = true) { if ($this->_identity === false) { if ($this->enableSession && $autoRenew) { $this->renewAuthStatus(); } else { return null; } } return $this->_identity; }
public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { /*在这里我var_dump(Yii::$app->user->isGuest ); 值为false, 执行下面一句$this->goBack() ,跳到主页后,var_dump(Yii::$app->user->isGuest ); 值变为true,表示未认证用户, 在这个问题纠结很久了, 也没思路去排错 ,,请指教下.*/ return $this->goBack(); } else { return $this->renderPartial ('login', [ 'model' => $model, ]); } }
//isGuest从这获取 public function getIsGuest() { return $this->getIdentity() === null; } //这个方法调用的$this->_identity,即是你上面那个方法设定的 //你上面那个方法也是传得一个参数进去的,它是一个实例于IdentityInterface接口的对像,具体实现自已写 //它里面有各种获取_identity的方法,比如findIdentity(),,, public function getIdentity($autoRenew = true) { if ($this->_identity === false) { if ($this->enableSession && $autoRenew) { $this->renewAuthStatus(); } else { return null; } } return $this->_identity; }
为什么我登录成功后,页面一跳转
$this->_identity
值变为null , 这样Yii::$app->user->isGuest
值又变成true了- bobysky 提出了问题Yii2.0 的用户登录问题