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 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. But a custom save handler fixed it:
namespace OurFramework\Session\SaveHandler;
class Cache extends \Zend\Session\SaveHandler\Cache
{
public function read($id)
{
return (string)parent::read($id);
}
}
The session config is as follows:
'session' => [
'cookie_lifetime' => '172800',
'cookie_secure' => '1',
'cookie_httponly' => '1',
'name' => 'some-session-name',
'save_handler' => 'redis',
'save_path' => "tcp://$host:$port?weight=1&timeout=3",
],
However, we also get warnings like session_regenerate_id(): Session object destruction failed. ID: user (path: tcp://host:port?weight=1&timeout=3) and session_destroy(): Session object destruction failed when users are logged out.
What may be causing these warnings on PHP 7.0.4 and how can they be fixed?