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)

Changes

Title unchanged

Single sign on across multiple subdomains

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

subdomain, domain, cookie, session

Content changed

[...]
**Explanation:**

* 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 :
 


```php
[...]
{
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.
 
 
 
```php 
class MyWebUser extends CWebUser
 
{
 
public function init()
 
{
 
$conf = Yii::app()->session->cookieParams;
 
$this->identityCookie = array(
 
'path' => $conf['path'],
 
'domain' => $conf['domain'],
 
);
 
parent::init();
 
}
``` **That's it !!!** This setup has been tested pretty thouroughly, but please provide comments/suggestions below on improving this article.
29 0
37 followers
Viewed: 64 337 times
Version: 1.1
Category: How-tos
Written by: ianaré
Last updated by: ianaré
Created on: Jan 25, 2011
Last updated: 13 years ago
Update Article

Revisions

View all history