Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

PHP 7 and redis session caching: session_regenerate_id(): Failed to create(read) session ID #35

Closed
aimfeld opened this issue Mar 23, 2016 · 3 comments · Fixed by #46
Closed

Comments

@aimfeld
Copy link

aimfeld commented Mar 23, 2016

We have been caching sessions with Redis in our Zend Framework 2 project (using zend-session 2.5.2) on PHP 5.6.

After upgrading from PHP 5.6 to PHP 7.0.4, there was a problem with redis session caching, resulting in the following error when users logged in: PHP message: PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: user.

We currently use a custom save handler to work around this problem:

namespace OurFramework\Session\SaveHandler;

class Cache extends \Zend\Session\SaveHandler\Cache
{    
    public function read($id)
    {
        return (string)parent::read($id);
    }
}

Maybe this fix could be added to Zend\Session\SaveHandler\Cache.

See this question on stackoverflow, and the discussion here.

@aimfeld
Copy link
Author

aimfeld commented Mar 24, 2016

This occurs in our dev-environment (laravel homestead) with phpredis version 2.2.8-devphp7 (there is no stable phpredis version for PHP 7 yet).

@necromant2005
Copy link
Contributor

The issue in php7 session bug: the session must exist to generate_session_id

@necromant2005
Copy link
Contributor

Sent pull request: #41

zluiten added a commit to zluiten/zend-session that referenced this issue Jun 18, 2016
weierophinney added a commit that referenced this issue Jun 24, 2016
Close #46
Close #44
Fixes #35
Fixes #36
Fixes #41
Fixes #42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants