Reputation: 6385
Here is my code, I've followed the basic example from Zend\Session documentation:
<?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>
I can see my data written to session but the PHPSESSID in the firebug shows that the cookie still contains the full domain (with subdomain - dom1.jt.martyndev, instead of .jt.martyndev)
Upvotes: 1
Views: 989
Reputation: 6385
OK, would seem that Zend's documentation is a little misleading? http://framework.zend.com/manual/current/en/modules/zend.session.config.html Listed under StandardConfig it has "name", "cookie_domain". However, the implementation within this class that should set the INI is:
/**
* 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;
}
Instead, I changed my code to SessionConfig and I can see in the inspector that the cookie domain is set as I wanted it:
use Zend\Session\Config\SessionConfig;
$config = new SessionConfig();
.
.
Upvotes: 1