Changing subdomain while logged in

I have a problem of keeping a user logged in when changing subdomains. When I login in then move to I am no longer logged in but when I return to I am still logged in. How can I fix this?

You must modfiy cookie params of session and user component (this only when using auto-login):

'components' => array(


   'session' => array(

      'cookieParams' => array('domain' => ''),



   'user' => array(

      'identityCookie' => array('domain' => ''),




Make sure there is a dot before the actual domain. Means the cookie is available on all subdomains.

How about the setState? Does this affect it?

No should work as usual.

More than a year later… and still i can’t get logged in. :blink:

No matter what I tried so far, I can’t get beyond that login page.

What if it’s a second-level domain like What values do I have to put in cookieParams and identityCookie if my domain is “” or “”? The site itself is on a shared host and in a subdirectory of the account’s root dir though I don’t think this is the problem.

— never mind problem solved with CDbHttpSession —

it’s okay as this login is for a limited amount of editors only so i don’t mind db sessions. also, it’s the first time i used this with yii so yii-hah! done that too.

still it’s bugging me why the cookies didn’t work. i may give it another try later on just to figure out why it wasn’t working on that particular server side. all config params seem to be alright and the cookie path is 777. maybe i just need a break.