这是我的代码,我遵循了Zend \ Session文档的基本示例:
<?php
require_once 'vendor/autoload.php';
use Zend\Session\Container;
use Zend\Session\SessionManager;
use Zend\Session\Config\StandardConfig;
$config = new StandardConfig();
$config->setOptions(array(
//'remember_me_seconds' => 1800,
//'name' => 'zf2',
'cookie_domain' => '.jt.martyndev',
));
$manager = new SessionManager($config);
Container::setDefaultManager($manager);
$container = new Container('namespace');
$container->item = 'foo';
?>
<pre><?php var_dump($_SESSION); ?></pre>
我可以看到我的数据写入会话但是firebug中的PHPSESSID显示cookie仍然包含完整的域(使用子域 - dom1.jt.martyndev,而不是.jt.martyndev)
答案 0 :(得分:1)
/**
* Set storage option in backend configuration store
*
* Does nothing in this implementation; others might use it to set things
* such as INI settings.
*
* @param string $storageName
* @param mixed $storageValue
* @return StandardConfig
*/
public function setStorageOption($storageName, $storageValue)
{
return $this;
}
/**
* Retrieve a storage option from a backend configuration store
*
* Used to retrieve default values from a backend configuration store.
*
* @param string $storageOption
* @return mixed
*/
public function getStorageOption($storageOption)
{
return;
}
相反,我将代码更改为SessionConfig,我可以在检查器中看到cookie域设置为我想要的:
use Zend\Session\Config\SessionConfig;
$config = new SessionConfig();
.
.