Doc #70520 [Ana]: session_regenerate_id() "Failed to create session ID" with custom SessionHandler

From: Date: Fri, 18 Sep 2015 09:47:25 +0000
Subject: Doc #70520 [Ana]: session_regenerate_id() "Failed to create session ID" with custom SessionHandler
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12764@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70520&edit=1 ID: 70520 User updated by: hpdl at oscommerce dot com Reported by: hpdl at oscommerce dot com Summary: session_regenerate_id() "Failed to create session ID" with custom SessionHandler Status: Analyzed Type: Documentation Problem Package: Session related Operating System: Win10 PHP Version: 7.0.0RC3 Assigned To: yohgaki Block user comment: N Private report: N New Comment: Thanks for the pointers here. The error occurred with my database session handler read() method returning a bool false instead of a string. This was only caught in RC3 as earlier 7dev releases and previous PHP versions did not produce any kind of error. Thanks for the time spent on this. Previous Comments: ------------------------------------------------------------------------ [2015-09-18 09:21:46] yohgaki@php.net I see error for read, but it will fail on both read/write due to wrong key size. ------------------------------------------------------------------------ [2015-09-18 09:19:20] yohgaki@php.net s/write/read/ ------------------------------------------------------------------------ [2015-09-18 09:18:26] yohgaki@php.net Found what's wrong. Current session save handler expects session read function returns STRING type when there is no error. However, the code public function read($id) { $data = parent::read($id); return @mcrypt_decrypt(MCRYPT_3DES, $this->key, $data, MCRYPT_MODE_ECB); } returns non string because $this->key is not valid key length. Apparently, the document has wrong size of key which results mcrypt_decrypt() error. This makes fail to write session data. Making documentation problem. ------------------------------------------------------------------------ [2015-09-18 09:05:41] requinix@php.net I tried it with a session_save_path(".") immediately before the session_start(). CWD was a local directory, and when I ran the code I posted earlier (in the same location) it worked correctly. ------------------------------------------------------------------------ [2015-09-18 09:03:03] yohgaki@php.net I got it right. I'll check it soon. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=70520 -- Edit this bug report at https://bugs.php.net/bug.php?id=70520&edit=1

« previous php.doc.bugs (#12764) next »