You have to set $cookieParams, by default the session cookie is only visible to the domain from which it was set.
'session'=>array(
'class' => 'CDbHttpSession',
'connectionID' => 'db',
'sessionTableName' => 'dbsession',
'cookieParams' => array(
'domain' => '.example.com', // cookie now visible on example.com and all subdomains
),
),
If you make use of CWebUser::$allowAutoLogin, you have to do the same for the user component. Instead of $cookieParams, it’s called CWebUser::$identityCookie.
Next, and this is the crucial bit with Yii (the above cookie configuration is generic PHP), the Yii application ID must be set in the config file:
array(
'id' => 'yourdomain',
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.