php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70133 Extended SessionHandler::read is ignoring $session_id when calling parent
Submitted: 2015-07-24 19:20 UTC Modified: 2016-01-15 20:41 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: lukas at owncloud dot com Assigned: yohgaki (profile)
Status: Closed Package: Session related
PHP Version: 5.6.11 OS: Mac OS X
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 - 13 = ?
Subscribe to this entry?

 
 [2015-07-24 19:20 UTC] 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()".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-29 02:14 UTC] yohgaki@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: yohgaki
 [2015-12-29 02:14 UTC] yohgaki@php.net
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?
 [2016-01-15 20:41 UTC] yohgaki@php.net
-Status: Verified +Status: Closed
 [2016-01-15 20:41 UTC] yohgaki@php.net
I added test cases for 7.0/master.

commit 9f2240963f75aa1d15c3ae2485e61635ec2c24fa

I closed this report, but feel free to re-open if anyone think this should be fixed in 5.6 also.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC