2

I've got an install of Magento 2.0 running on Centos 6.7 with PHP 7. I'm using Redis for cache and Memcached for session data. Everything so far on the frontend works great, but I'm getting the following error when I try to log into the backend.

Recoverable Error: session_regenerate_id(): Failed to create(read) session ID: user (path: 127.0.0.1:11211)

I did some research on Google and found posts on Github from both Inchoo and colinmollenhour that say that the issue is that the session data that's being returned can sometimes be the boolean false instead of a string. From what I can gather PHP 5 was fine with getting the boolean false whereas PHP 7 must have a string returned. So their solution was to cast the session data variable as a string. The problem for me is that their solution is for Magento 1.x and I'm working with Magento 2.

So I did some more research/code diving and the closest thing I could find was in vendor/magento/framework/Session/SaveHandler/DbTable.php where in the read() function I cast the returned $data variable as a string. Didn't work although I don't think that's the right spot. So does anyone know where the read() function for reading session data when using Memcached is at and/or how to fix this particular issue in Magento 2?

4

I'm having the same issue when I upgraded my stack to PHP 7 to do some M2 performance testing.

The temporary fix is in the SaveHandler.php file: /vendor/magento/framework/Session/SaveHandler.php

Cast the return value for the read function and you'll be good to go.

Here's the issue I logged on M2's github page: https://github.com/magento/magento2/issues/2827

  • Yep! Worked like a charm! Hopefully Magento will push that out as a permanent fix quickly. – Mike Levy Dec 28 '15 at 20:14
1

Hi this is a php / memcached bug related: https://bugs.php.net/bug.php?id=71187

Work around:

class MemcachedSession extends SessionHandler { public function read($session_id) { return (string)parent::read($session_id); } }

$sess = new MemcachedSession(); session_set_save_handler($sess, true);

session_start(); $_SESSION['value'] = session_id(); session_regenerate_id(); ?>"

1

It looks like these patches tackle this session handler issue in PHP 7 core: https://github.com/php/php-src/blob/PHP-7.0/NEWS#L46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.