Bug #71187 [Com]: session_regenerate_id(): Failed to create(read) session
Edit report at https://bugs.php.net/bug.php?id=71187&edit=1
ID: 71187
Comment by: coldfff at gmail dot com
Reported by: akauffman at ne4u dot com
Summary: session_regenerate_id(): Failed to create(read)
session
Status: Assigned
Type: Bug
Package: Session related
Operating System: Ubuntu 14.04 LTS
PHP Version: 7.0.1
Assigned To: yohgaki
Block user comment: N
Private report: N
New Comment:
In case its any easier for testing, this bug is affecting me too using the Cache Savehandler from
ZF2.
The workaround as suggested can also be applied there:
<?php
use Zend\Session\SaveHandler\Cache as ZendCache;
class Cache extends ZendCache
{
public function read($id)
{
return (string) parent::read($id);
}
}
Previous Comments:
------------------------------------------------------------------------
[2015-12-22 05:08:02] yohgaki@php.net
When I ported the save handler, I think I made sure it returns string always for successful cases.
I'll have a look shortly.
@akauffman, could you give info where did you get the memeached module source code? Just making sure
to get the same code.
------------------------------------------------------------------------
[2015-12-21 20:39:29] akauffman at ne4u dot com
Description:
------------
There seems to be a type casting problem with custom session handlers (specifically the memcached
module) when session_regenerate_id() is called. Perhaps related to a null return value. It looks
like it was introduced around 7RC3.
Error:
PHP message: PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID:
user
Test script:
---------------
Problem:
<?php
set_ini('session.save_handler','memcached');
set_ini('session.save_path','host1:11211');
session_start();
$_SESSION['value'] = session_id();
session_regenerate_id();
?>
Work around:
<?php
set_ini('session.save_handler','memcached');
set_ini('session.save_path','host1:11211');
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();
?>
Expected result:
----------------
Shouldn't have to implement a workaround.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71187&edit=1
Thread (7 messages)