Yii2 Advanced应用程序,带有子域的前端和后端的不同会话
我的Yii2应用程序有问题. 我有一个在不同域(子域)上具有前端和后端部分的高级应用程序.我使用了webvimark用户管理模块,但我认为问题不在于此.
I have a problem with my Yii2 app. I have a advanced-app with frontend and backend parts on different domains (subdomain). I use webvimark user management module, but I think the problem is not in it.
前端应用-> domain.com
后端应用-> admin.domain.com
Frontend app -> domain.com
Backend app -> admin.domain.com
所以我在后端登录时遇到问题,它不起作用.
输入登录名和密码,提交表单后,我再次看到登录表单.
So I have problem with login in backend, it is not working.
I enter login and password, and after submit form I see login form again.
'user' => [
'identityClass' => 'webvimark\modules\UserManagement\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendIdentity',
'domain' => 'admin.domain.com',
],
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
],
和
'session' => [
'name' => 'BACKENDSESSID',
'cookieParams' => [
'domain' => 'admin.domain.com',
],
],
有什么想法吗?
更新#1:我的配置位于:/backend/config/main.php
更新#2:在子域上传输后端时出现问题
Update #1: My config located: /backend/config/main.php
Update #2: There was a problem when transferring backend on a subdomain
好吧,模块的配置存在问题,并且前端的配置错误.
Okey, there was a problem with the configuration of the module, as well as the wrong config in the frontend.
后端:
'user' => [
'identityClass' => 'webvimark\modules\UserManagement\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendIdentity',
'domain' => 'backend.test.dev',
],
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
'on afterLogin' => function ($event) {
\webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
},
],
'session' => [
'name' => 'BACKENDSESSID',
'cookieParams' => [
'domain' => 'backend.test.dev',
],
],
前端:
'user' => [
'identityClass' => 'webvimark\modules\UserManagement\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_frontendIdentity',
'path' => '/',
],
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
'on afterLogin' => function ($event) {
\webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
}
],
'session' => [
'name' => 'FRONTENDSESSID',
'cookieParams' => [
'path' => '/',
],
],