Session For Subdomains And Multiple Domains At The Same Time?

Hi,

I am currently setting cookieParams for my session in my config file to allow session to be used across subdomain:


array( 'domain' => '.mysite.com' )

I implemented a custom domain feature allowing my user to use any custom domain. With the above code, session does not work under a custom domain. If I take out the above code, session works under the custom domain, but session is not shared between subdomains.

Is there a way to make session work under custom domain while having subdomains share the session?

TIA

Try this:




'session' => array(

    'cookieParams' => array('domain' => '.mysite.com'),

),

'user' => array(

    ...

    'identityCookie' => array('domain' => '.mysite.com'),

    ....

),




Of course, all the domains must be on the same server. In case of different servers consider using shared sessin store like memcached.

Thanks for the reply. I don’t quite follow. I am using CDbHttpSession for session. With the code you provided, it seems that session is not working for custom domains i.e. somecustomdomain.com.

I ended up setting the cookieParams dynamically in my root Controller by looking at the request hostInfo




Yii::app()->session->setCookieParams( array('domain' => '.mysite.com') );

Yii::app()->session->open();