Fixing session_regenerate_id(): Failed to create(read) session ID error

I spent a bit of time tracking down a session-related error that was occurring after upgrading PHP from version 5 to version 7:

PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: user (path: /var/lib/php/session) in /vagrant/library/Zend/Session.php on line 322

Although this particular error was coming from Zend Framework, there’s a more general solution that is framework-agnostic:

If you are setting a custom session handler, make sure the read callback returns a string. Returning null or false will cause the above error.


Glen Scott

I’m a freelance software developer with 18 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork. I am the Managing Director of Yellow Square Development.

More Posts

Follow Me:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.