Bug #71187 [Asn]: session_regenerate_id(): Failed to create(read) session

[email protected] ("akauffman at ne4u dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71187&edit=1

 ID:                 71187
 User updated by:    akauffman at ne4u 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:

Memcache with php7:


$ git clone https://github.com/php-memcached-dev/php-memcached
$ cd php-memcached
$ git checkout -b php7 origin/php7

$ /usr/local/php7/bin/phpize
$ ./configure --with-php-config=/usr/local/php7/bin/php-config
$ make
$ sudo make install


modules.ini
# Memcached
extension=memcached.so


Previous Comments:
------------------------------------------------------------------------
[2015-12-22 14:22:30] coldfff at gmail dot com

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);
    }
}

------------------------------------------------------------------------
[2015-12-22 05:08:02] [email protected]

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.