2013-06-20 29 views
0

我有3個領域:Zend的第二節常見的cookie域

example.com 
m.example.com 
dev.example.com 

會議應example.comm.example.com是共同的。我是如何做到的。 bootstrap.php中:

protected function _initSession() 
{ 
     Zend_Session::setOptions(array(
      'cookie_domain' => '.example.com', 
      'name'   => 'ExampleSession' 
     )); 
     Zend_Session::start(); 
} 

但是這屆作品dev.example.com了。我如何避免dev.example.com的常見會話?謝謝!

回答

3

我認爲使這成爲可能的唯一方法是根據主機名動態設置Cookie域。

它可能是這個樣子:

protected function _initSession() 
{ 
     Zend_Session::setOptions(array(
      'cookie_domain' => ($_SERVER['HTTP_HOST'] == 'dev.example.com' ? 'dev.example.com' : '.example.com'), 
      'name'   => 'ExampleSession' 
     )); 
     Zend_Session::start(); 
}