Hi there,
I try to implement a cross sub.domain "sign on". Meaning I login on exemple.com and sub.exemple.com will still logged in.
[color="#0000FF"]I work with a multi-tenant application. Meaning the domain name change.[/color]
I followed the instruction here: Cross Sub Domain Tutorial and it works flawlessly.
…Well with a regular static webapp.
I just have to set in main.php
'session' => array(
'savePath' => '/var/www/haha/open',
'cookieMode' => 'allow',
'cookieParams' => array(
'path' => '/',
'domain' => '.awesomexemple.com', //THIS MUST BE DYNAMIC!
'httpOnly' => true,)
),
But in my case I must set the domain on the fly…
BEFORE the session_start()… I tried:
class Controller extends CController
{
...
public function init()
{
$this->setCrossSubDomainCookies();
}
public function setCrossSubDomainCookies()
{
$values = array('savePath' => '/var/www/gtbHosting/open',
'cookieMode' => 'allow',
'cookieParams' => array(
'path' => '/',
'domain' => '.' . Yii::app()->tenant->getDomainName(), //This is how I get the tenant domain!
'httpOnly' => true,));
Yii::app()->session->setCookieParams($values);
}
[color="#FF0000"]It doesn’t work[/color]
[color="#008000"][size="5"]Question[/size]
How can I configure my session without using a static call: main.php
Say in Controller::init()?[/color]