J
J
jekahm2015-01-03 05:52:02
Yii
jekahm, 2015-01-03 05:52:02

How to correctly implement authentication on subdomains in Yii2?

Good day!
I ran into a problem that I don't understand.
Implemented user authentication on different subdomains in Yii2 (basic), using the following code in the config:

'user' => [
  //'class' => 'yii\web\User',
  'identityClass' => 'app\models\Users',
  'enableAutoLogin' => true,
  'identityCookie' => [
    'name' => '_identity',
    'httpOnly' => true,
    'path' => '/',
    'domain' => '.testproject.local',
  ],
],
'session' => [
  //'savePath' => '\app\session',
  'cookieParams' => [
    'domain' => '.testproject.local',
    //'httpOnly' => true,
    //'path' => '/',
  ],
],

Authentication successfully occurs on the required subdomains (ru and en in this case). But if I can still logout from subdomains, then this simply does not happen on the main domain. That is, the user remains permanently logged in there. I tried to remove the enableAutoLogin parameter. Everything starts working as it should in terms of delogging. But after closing the browser and reopening it, the user will then need to log in again. And this is not good. Here is such an incomprehensible situation.
Thanks in advance to everyone for help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question