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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 19:01:34 2025 UTC