0

私は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ですか? ありがとう!

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 に答える