I have do a website with Yii, it use wildcard subdomain. To control the session, I use CDbHttpSession
Here is the code in main.php
'session'=>array(
'class' => 'CDbHttpSession',
'connectionID' => 'db',
'sessionTableName' => 'dbsession',
),
When login in with domain 'www.xxx.com', then it will redirect to 'subdomainname.xxx.com'.
But now, the user show it's not login in subdomainname.xxx.com, when change url to www.xxx.com, it show user is login.
Is there anything I do wrong?
Any reply is appreciate!
Page 1 of 1
wildcard subdomain with CDbHttpSession issue wildcard subdomain with CDbHttpSession issue
#2
Posted 13 November 2010 - 12:53 PM
You have to set $cookieParams, by default the session cookie is only visible to the domain from which it was set.
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.
'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.
#3
Posted 13 November 2010 - 01:01 PM
Y!!, on 13 November 2010 - 12:53 PM, said:
You have to set $cookieParams, by default the session cookie is only visible to the domain from which it was set.
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.
'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.
It works like a charm, thank you very much! really appreciate!
#4
Posted 14 March 2011 - 10:54 AM
Quote
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.
how to manage this? didnt understand!
plz help
#5
Posted 18 March 2011 - 10:23 AM
#6
Posted 11 May 2012 - 08:54 AM
Thanks Y!!, I've struggled with this for the past few days. My problem was with Chrome because IE worked fine.
José
Share this topic:
Page 1 of 1

Help













