Yii2 Advanced app, different session for frontend and backend with subdomains

╄→гoц情女王★ 提交于 2019-12-06 02:41:54

Okey, there was a problem with the configuration of the module, as well as the wrong config in the frontend.

Backend:

'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',
        ],
    ],

Frontend:

'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'     => '/',
        ],
    ],
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!