我有三个域名:
example.com
m.example.com
dev.example.com
Session对于example.com
和m.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
的常见会话?谢谢!
我认为唯一可行的方法是根据主机名动态设置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();
}