php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63358 Bug session_set_save_handler() in write function
Submitted: 2012-10-25 10:22 UTC Modified: 2012-10-25 10:27 UTC
From: snake at talitasia dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.3.18 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: snake at talitasia dot com
New email:
PHP Version: OS:

 

 [2012-10-25 10:22 UTC] snake at talitasia dot com
Description:
------------
write(string $sessionId, string $data)
The write callback is called when the session needs to be saved and closed. This 
callback receives the current session ID a serialized version the $_SESSION 
superglobal.

When the variable $_SESSION hasn't got a value the value returned is string(0).

Test script:
---------------
<?php
class Handler
{
	public function write( $SessionID, $sData )
	{
		var_dump( serialize( $_SESSION ) ); // Real $sData Value
		var_dump( $sData ); // Return string(0)...
	}
	public function open( $sSavePath, $sSessionName ){return true;}
	public function close(){}
	public function read( $SessionID ){}
	public function destroy( $SessionID ){}
	public function gc( $iMaxLifeTime ){return true;}
}

$Handler = new Handler();
session_set_save_handler( array( $Handler, 'open' ), array( $Handler, 'close' ), array( $Handler,
		'read' ), array( $Handler, 'write' ), array( $Handler, 'destroy' ), array( $Handler, 'gc' ) );
session_start();
session_write_close();
?>

Expected result:
----------------
string(6) "a:0:{}" string(6) "a:0:{}"

Actual result:
--------------
string(6) "a:0:{}" string(0) ""

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-25 10:27 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

this "serialize" is not that "serialize", see: 
http://php.net/manual/en/function.session-encode.php
 [2012-10-25 10:27 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC