This paper introduces the

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


, 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']; )


4.1 test

4.2 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: | 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!