【问题标题】:Zend Session 2 common cookie domainsZend Session 2 常用 cookie 域
【发布时间】:2013-06-20 07:43:37
【问题描述】:

我有 3 个域:

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 的共同会话?谢谢!

【问题讨论】:

    标签: php apache zend-framework session subdomain


    【解决方案1】:

    我认为使这成为可能的唯一方法是根据主机名动态设置 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();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-04
      • 1970-01-01
      • 2014-03-05
      • 2014-05-20
      • 1970-01-01
      • 1970-01-01
      • 2014-05-02
      • 2014-08-02
      相关资源
      最近更新 更多