php - Automagically Log into Multiple Domains in Yii2 -
i have site root domain , several sub domains, each separate yii2 module. @ moment have log each sub domain individually. want able log root directory , automatically logged each of sub domains. there few pages here , there on web achieving nothing works.
at moment have same setup in both main.php config files (i.e. root domain , 1 of sub domains testing with)
'components' => [ 'request' => [ 'enablecookievalidation' => true, 'enablecsrfvalidation' => true, 'cookievalidationkey' => 'xxxxxxx', ], 'user' => [ 'class' => 'yii\web\user', 'identityclass' => 'common\models\user', 'enableautologin' => true, 'identitycookie' => [ 'name' => '_myapp', 'httponly' => true, 'path' => '/', ] ], 'session' => [ 'name' => 'myappsessid', 'cookieparams' => [ 'path' => '/', ], ], when inspecting cookies in chrome after logging in setup see 2 cookies, 1 main site , 1 sub domain, both called myappsessid, , both containing different 'keys' presumably hook user info set on php session. these 2 cookies should 1 cookie both domains hook session user object - i;ve tried different settings can think of , can't work.
to able log on subdomains, use following config:
'components' => [ 'session' => [ // ... 'cookieparams' => [ 'path' => '/', 'domain' => ".domain.com", ], ], 'user' => [ // ... 'identitycookie' => [ 'name' => '_identity', 'path' => '/', 'domain' => ".domain.com", ], ], 'request' => [ // ... 'csrfcookie' => [ 'name' => '_csrf', 'path' => '/', 'domain' => ".domain.com", ], ], ],
Comments
Post a Comment