Difference between #5 and #6 of
Single sign on across multiple subdomains

Revision #6 has been created by ianaré on Feb 2, 2011, 11:18:23 AM with the memo:

update user class info
« previous (#5)


Title unchanged

Single sign on across multiple subdomains

Category unchanged


Yii version unchanged

Tags unchanged

subdomain, domain, cookie, session

Content changed


* The Yii application ID is used to generate a unique signed key, used as a prefix to access user state information. The ID should be set manually so that it is identical for each Yii application that needs to share cookies and sessions.

Finally, the user cookie parameters must also be set to be identical as in the configuration file :

public $identityCookie = array(
'path' => '/', 'domain' => '.yourdomain.com', 'httpOnly' => true
Or you can grab the settings from the configuration settings. This is especially useful when the settings will change, for example to set different domain names and/or paths for local, pre-production and production environments.
class MyWebUser extends CWebUser
public function init()
$conf = Yii::app()->session->cookieParams;
$this->identityCookie = array(
'path' => $conf['path'],
'domain' => $conf['domain'],
``` **That's it !!!** This setup has been tested pretty thouroughly, but please provide comments/suggestions below on improving this article.
29 0
Viewed: 55 594 times
Version: 1.1
Category: How-tos
Written by: ianaré
Last updated by: ianaré
Created on: Jan 25, 2011
Last updated: 9 years ago
Update Article


View all history