Yii2:前端用户注销,但后端仍然登录



我遇到了一个问题,当我从前端或后端注销时,另一个仍然登录。我一直在网上搜索解决方案,但没有找到这样的东西。我应该更改什么,以便在从前端或后端注销时,另一个必须注销。

登录对两者都很好:

public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}

请更新您的前端和后端main.php,如下所示

'user' => [
'identityClass' => 'commonmodelsUser',
'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和会话相同,就可以从前端和后端管理会话。

最新更新