我遇到了一个问题,当我从前端或后端注销时,另一个仍然登录。我一直在网上寻找解决方案,但没有找到类似的东西。我应该更改什么,以便当我从前端或后端注销时,另一个必须注销。
登录对两者都正常工作:
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
答案 0 :(得分:0)
请更新您的前端和后端 main.php 如下
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-auth', 'httpOnly' => true],
],
'session' => [
// this is the name of the session cookie used for login on the frontend
'name' => 'AuthSession',
],
一旦 identityCookie 和会话相同,那么您就可以从前端和后端管理您的会话。