Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session_regenerate_id() error found. #818

Closed
daisukeiip opened this Issue May 31, 2016 · 19 comments

Comments

Projects
None yet
@daisukeiip
Copy link

daisukeiip commented May 31, 2016

Please check.

Source code

session_start();
session_regenerate_id(true);

Error message

Severity: 4096 --> session_regenerate_id(): Failed to create(read) session ID: rediscluster (path: seed[]=192.168.23.0:6379&seed[]=192.168.23.1:6379&seed[]=192.168.23.2:6379&seed[]=192.168.23.3:6379&seed[]=192.168.23.4:6379&seed[]=192.168.23.5:6379&timeout=3&read_timeout=3&failover=error) /usr/share/nginx/service_0/application/controllers/Test.php 20

PHP settings

> vi php.d/redis.ini

session.save_handler=rediscluster
session.save_path="seed[]=192.168.23.0:6379&seed[]=192.168.23.1:6379&seed[]=192.168.23.2:6379&seed[]=192.168.23.3:6379&seed[]=192.168.23.4:6379&seed[]=192.168.23.5:6379&timeout=3&read_timeout=3&failover=error"

Environment

  • CentOS 6.7 (64bit)
  • PHP 7.0.6
  • PHP-FPM 7.0.7
  • Nginx-1.10.0
  • Redis 3.0.7
@jmara

This comment has been minimized.

Copy link

jmara commented Aug 1, 2016

Still the case with the most recent version of the module?

Cheers,
Jan

@arkhamvm

This comment has been minimized.

Copy link

arkhamvm commented Aug 2, 2016

@jmara, I'm getting same error too, tested on latest PHP7 branch version.
Profiling:

**17531 14:09:32.621020 sendto(16, "*2\r\n$3\r\nGET\r\n$57\r\nPHPREDIS_CLUSTER_SESSION:46ce3e17ca86e3408bd188a82f9fb833\r\n", 77, MSG_DONTWAIT, NULL, 0) = 77**
17531 14:09:32.621080 poll([{fd=16, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 1 ([{fd=16, revents=POLLIN}])
17531 14:09:32.621115 recvfrom(16, "$", 1, MSG_PEEK, NULL, NULL) = 1
17531 14:09:32.621147 poll([{fd=16, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=16, revents=POLLIN}])
**17531 14:09:32.621181 recvfrom(16, "$-1\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 5**
17531 14:09:32.621216 poll([{fd=16, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
17531 14:09:32.621285 chdir("/home/web/cgi-bin") = 0
**17531 14:09:32.621335 stat("/home/web/my/php/project/ErrorException.php", {st_mode=S_IFREG|0664, st_size=3798, ...}) = 0**

Env mostly the same (ubuntu instead centos).

@fperske

This comment has been minimized.

Copy link

fperske commented Nov 3, 2016

same error with

  • phpredis 3.0.0
  • php-fpm 7.0.12
  • redis 3.2.4 in cluster-mode:

Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: rediscluster (path: seed[]=192.168.108.241:6379&seed[]=192.168.108.242:6379&seed[]=192.168.108.243:6379&timeout=2&read_timeout=2&failover=error&persistent=1) in test.php on line 3

with test.php:

<?php
session_start();
session_regenerate_id(true);
?>

and php.ini:

session.save_handler = rediscluster
session.save_path = "seed[]=192.168.108.241:6379&seed[]=192.168.108.242:6379&seed[]=192.168.108.243:6379&timeout=2&read_timeout=2&failover=error&persistent=1"
@fperske

This comment has been minimized.

Copy link

fperske commented Nov 4, 2016

Error also occurs with phpmyadmin (latest 4.6.4). same environment as above

Catchable Fatal Error in ./libraries/session.lib.php#20
session_regenerate_id(): Failed to create(read) session ID: rediscluster (path: seed[]=192.168.108.241:6379&amp;seed[]=192.168.108.242:6379&amp;seed[]=192.168.108.243:6379&amp;timeout=2&amp;read_timeout=2&amp;failover=error&amp;persistent=1)

Backtrace

./libraries/session.lib.php#20: session_regenerate_id(boolean true)
./libraries/common.inc.php#733: PMA_secureSession()
./index.php#13: require_once(./libraries/common.inc.php)

Phpredis is therefore not suitable for productive use. Can you please correct this issue?

@ephramm

This comment has been minimized.

Copy link

ephramm commented Nov 4, 2016

Hi,

I am having the same issue.

  • phpredis 3.0.0
  • libapache2-mod-php 7.0.12
  • redis 3.2.1 in cluster mode

Thanks for looking into this.

@dmytro-pe

This comment has been minimized.

Copy link

dmytro-pe commented Nov 29, 2016

Hello.

I have same issue with:

  • phpredis 3.0.0
  • redis 3.2.5 in cluster mode
  • php 7.0.13

Thank you very much! session_regenerate_id(..) does not work correctly.

@leuchtdiode

This comment has been minimized.

Copy link

leuchtdiode commented Dec 16, 2016

I'm getting the issue

PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: redis (path: tcp://[ip]:6379) in /.../zendframework/zendframework1/library/Zend/Session.php on line 320

on:

  • Red Hat 7.3
  • phpredis 3.1.0
  • redis 3.2.6 not in cluster mode
  • php 7.0.14

The weird thing is: I don't get the error on 3.0.0.

Any ideas?

Thx,
Alex

@inwel

This comment has been minimized.

Copy link

inwel commented Dec 30, 2016

I had the same problem and found it to be a wrong variable type. The session handlers read method is expected to return a string. This workaround fixes it:

<?php
ini_set('display_errors', true);
class MySessionHandler extends SessionHandler
{
        public function read($session_id) {
                return (string)parent::read($session_id);
        }
}

$MySessionHandler = new MySessionHandler();
session_set_save_handler($MySessionHandler, true);

session_start();
var_dump(session_id());

session_regenerate_id(true);
var_dump(session_id());
?>

also see: https://bugs.php.net/bug.php?id=71187

@mahngiel

This comment has been minimized.

Copy link

mahngiel commented Jan 13, 2017

Came across this as well with Docker php:7.0-apache + redis-3.1.0 with Redis version 3.2.6.

Confirm workaround posted above works. Here's usage with PHP7's anonymous class

/**
 * @link https://github.com/phpredis/phpredis/issues/818
 * For PECL Redis 3.1.0,
 */
session_set_save_handler( new class extends \SessionHandler {
    public function read( $session_id )
    {
        return (string)parent::read( $session_id );
    }
}, true);
@jportoles

This comment has been minimized.

Copy link

jportoles commented Jan 13, 2017

I'm seeing this issue as well. I think that commit 18c7ab0 should fix it, but 3.1.1 is not published on PECL yet.

@madsi1m

This comment has been minimized.

Copy link

madsi1m commented Feb 8, 2017

Has this been fixed yet?

Doesn't seem to be we are working for me:

php70-php-pecl-redis-3.1.1-1.el7.remi.x86_64
Redis 3.2.7

@madsi1m

This comment has been minimized.

Copy link

madsi1m commented Mar 1, 2017

Hi any updates on this?

@jportoles

This comment has been minimized.

Copy link

jportoles commented Mar 1, 2017

@madsi1m 3.1.1 is up on PECL (https://pecl.php.net/package/redis), it should resolve it if you have it installed properly.

@spsellars

This comment has been minimized.

Copy link

spsellars commented Mar 1, 2017

I was getting the same error even with 3.1.1, turned out to be due to this bug related to older kernels (which many OpenVZ VPS providers leave you stuck with.) Recompiling PHP with the updated random.c file fixed it.

@madsi1m

This comment has been minimized.

Copy link

madsi1m commented Mar 1, 2017

looks like it is working again. Thanks for the update

@daisukeiip

This comment has been minimized.

Copy link
Author

daisukeiip commented Aug 31, 2017

PHP5.6 "session_regenerate_id(true)" operate normally. but PHP7 dosen't.
session.save_handler = rediscluster

[environment]
CentOS 7 + Redis 3.0.7 (Cluster)

$ yum list installed | grep -e php-pecl-redis -e nginx -e php-fpm -e php.x86_64

nginx.x86_64
php.x86_64                      7.1.8-1.el7.remi               @remi-php71      
php-fpm.x86_64                  7.1.8-1.el7.remi               @remi-php71      
php-pecl-redis.x86_64           3.1.2-1.el7.remi.7.1           @remi-php71 

$ cat /etc/php.d/50-redis.ini

...
session.save_handler = rediscluster
session.save_path = "seed[]=192.168.23.0:6379&seed[]=192.168.23.1:6379&seed[]=192.168.23.2:6379&seed[]=192.168.23.3:6379&seed[]=192.168.23.4:6379&seed[]=192.168.23.5:6379&timeout=3&read_timeout=3&failover=error&persistent=1"
...

$ cat /usr/share/nginx/html/index.php

<?php
session_start();
echo session_id();	// nvc43occpeecjkt32pmoivodpn
session_regenerate_id(true);
echo session_id();	// nvc43occpeecjkt32pmoivodpn (dosen't change)

@michael-grunder

This comment has been minimized.

Copy link
Member

michael-grunder commented Aug 31, 2017

Thanks I'll take a look.

@yatsukhnenko

This comment has been minimized.

Copy link
Member

yatsukhnenko commented Aug 31, 2017

@yatsukhnenko

This comment has been minimized.

Copy link
Member

yatsukhnenko commented Oct 20, 2017

Fixed in >= 3.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.