ZF2-242: Session don't set savePath via DI configuration

Issue Type: Bug Created: 2012-03-28T13:18:59.000+0000 Last Updated: 2012-03-29T19:26:14.000+0000 Status: Closed Fix version(s): Reporter: Igor Bakulin (fenix8422) Assignee: Mike Willbanks (digitalstruct) Tags: - Zend\Session

Related issues: Attachments:



Functions setSavePath and setEntropyFile has same name parameter "$path".

If you try to configure Session via DI like this 'Zend\Session\Configuration\SessionConfiguration' => array( 'parameters' => array( 'savePath' => DIR . '/../../session', 'rememberMeSeconds' => 24_3600_1, 'cookieLifetime' => 24_3600_1, ) ), session.save_path won't set. If change 'savePath' => 'path' DI will call function setEntropyFile.

Solution is rename $path param to $savePath in 'setSavePath' function:

public function setSavePath($savePath) { if (!is_dir($savePath)) { throw new Exception\InvalidArgumentException('Invalid save_path provided'); } $this->savePath = $savePath; $this->setStorageOption('save_path', $savePath); return $this; }


Posted by Mike Willbanks (digitalstruct) on 2012-03-28T13:59:17.000+0000

Posted by Igor Bakulin (fenix8422) on 2012-03-29T06:06:57.000+0000

You changed function getStorageOption parameter, but you forgot change $name variable to $storageOption variable in function body (file SessionConfiguration).

Have to change:

<pre class="highlight">
public function getStorageOption($storageOption)
        $key       = false;
        $transform = false;
        switch ($storageOption) {
            case 'remember_me_seconds':
                // No remote storage option; just return the current value
                return $this->rememberMeSeconds;
            case 'url_rewriter_tags':
                $key = 'url_rewriter.tags';
            // The following all need a transformation on the retrieved value;
            // however they use the same key naming scheme
            case 'use_cookies':
            case 'use_only_cookies':
            case 'use_trans_sid':
                $transform = function ($value) {
                    return (bool) $value;
                $key = 'session.' . $storageOption;

        $value = ini_get($key);
        if (false !== $transform) {
            $value = $transform($value);
        return $value;

Posted by Mike Willbanks (digitalstruct) on 2012-03-29T15:19:09.000+0000

Updated pull request

Posted by Mike Willbanks (digitalstruct) on 2012-03-29T19:26:14.000+0000

Change has been pushed to master:

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.