Bug #70133 [Opn->Ver]: Extended SessionHandler::read is ignoring $session_id when calling parent

From: Date: Tue, 29 Dec 2015 02:14:14 +0000
Subject: Bug #70133 [Opn->Ver]: Extended SessionHandler::read is ignoring $session_id when calling parent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198269@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70133&edit=1

 ID:                 70133
 Updated by:         yohgaki@php.net
 Reported by:        lukas at owncloud dot com
 Summary:            Extended SessionHandler::read is ignoring
                     $session_id when calling parent
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Session related
 Operating System:   Mac OS X
 PHP Version:        5.6.11
-Assigned To:        
+Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

Although I didn't intend fixing this bug in PHP 7, it's fixed in PHP 7. I did some
cleanups in PHP 7. It seems it fixed this. Should I fix this in PHP 5.6?


Previous Comments:
------------------------------------------------------------------------
[2015-07-24 19:20:28] lukas at owncloud dot com

Description:
------------
When extending \SessionHandler's read method and calling the parent method the session data is
still read from the session returned by the PHP function "session_id()" instead of the
defined session id.

As a workaround it is possible to use session_id('mycustomsession') before
reading the value and resetting it to the previous value. Note that the test script is not a
real-world scenario and just illustrating the behaviour.

Test script:
---------------
<?php

class CustomReadHandler extends \SessionHandler {

	public function read($session_id) {
		parent::read('mycustomsession');
	}
}
session_set_save_handler(new CustomReadHandler(), true);

session_start();
$_SESSION['foo'] = 'bar';
var_dump($_SESSION);

Expected result:
----------------
The session mycustomsession is used. Instead the session returned by "session_id" id is
used. Data is thus stored in sess_jtmv4c76rqarqpt475ptkskr15 instead of sess_mycustomsession.

Actual result:
--------------
Data is read from the session defined by the PHP function "session_id()".


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70133&edit=1


Thread (3 messages)

« previous php.bugs (#198269) next »