我有3个域名:
example.com
m.example.com
dev.example.com
会话应该是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
的常见会话?谢谢!
答案 0 :(得分: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();
}