Yii2 Advanced应用程序,带有子域的前端和后端的不同会话 [英] Yii2 Advanced app, different session for frontend and backend with subdomains

查看:77
本文介绍了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'     => '/',
        ],
    ],

这篇关于Yii2 Advanced应用程序,带有子域的前端和后端的不同会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆