0

我有 3 个域:

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

example.com会话对于和应该是通用的m.example.com。我是怎么做到的。引导程序.php:

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

但本次会议dev.example.com也适用。我怎样才能避免共同会话dev.example.com?谢谢!

4

1 回答 1

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();
}
于 2013-06-20T08:30:17.247 回答