This paper introduces the

method to realize SSO in Yii2, for everyone to share, as follows:

/common/config/main.php

, in config on the head with the following code

 < / / Session? PHP cross domain $host = explode ($_SERVER[', "HTTP_HOST"]); if (count ($host) > 2 ('DOMAIN', $host[1]) {define}. '.'. $host[2]); else {define ('DOMAIN', $host[0]. $host[1]. 

.');}

two, config components joined

 < configuration; PHP'user'=>? ['identityClass''commonmodelsUser','enableAutoLogin' => => true'identityCookie'=> ['name' =>'_identity''httpOnly' => True,'domain', =>'.'.DOMAIN],'session', => ['domain'=> =>'cookieParams';'.'.DOMAIN'lifetime'=>'timeout' => 0], 3600,] strong>

 < 

, use the < / style= "

controller, three; PHP? / / set Yii:: $app-> session['var']='value'; / / echo Yii:: $app-> session['var']; / / remove unset (Yii:: $app-> session['var']; )

four,

4.1 www.aaa.com test

4.2 www.bbb.com landing

session still has the effect.

is the whole content of this article, I hope to help you, and hope that you can support a lot of scripting home.

This paper fixed link:http://www.script-home.com/the-method-of-realizing-single-sign-on-in-yii2.html | Script Home | +Copy Link

Article reprint please specify:The method of realizing single sign on in Yii2 | Script Home

You may also be interested in these articles!