D
D
Doniyor Mamatkulov2019-10-29 20:52:48
Yii
Doniyor Mamatkulov, 2019-10-29 20:52:48

How to use single sessions on different domains and sites?

Hello.
The situation is this: there are two physical servers. The first is site.com (Yii2 advanced) and the second is abc.site.com (Yii2 basic). It is necessary to organize joint sessions based on Yii2, so that when a user logs in to site.com and goes to abc.site.com, this user's authorization session is saved. Is this even possible? If so, please provide links with examples. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-10-29
@doniyorbekm

'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache',
            'cachePath' => '@frontend/runtime/cache' //делаем общий кеш
        ],
        'request' => [
            'csrfParam' => '_csrf-myap', //тоже делаем такое же как и на frontend
            'cookieValidationKey' => 'nk34HGdd8w6rf', //тоже делаем такое же как и на frontend
        ],

'user' => [
    'identityClass' => 'common\models\User',
    'enableAutoLogin' => true,
    'identityCookie' => [
        'name' => '_identity',
        'httpOnly' => true,
        'domain' => '.' . DOMAIN,
    ],
],
'session' => [
    'cookieParams' => [
        'domain' => '.' . DOMAIN,
        'httpOnly' => true,
    ],
],

To index
defined('DOMAIN') or define('DOMAIN', 'mysite.com');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question