php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30536 Can't write to $_SESSION in the __destructor()
Submitted: 2004-10-22 21:51 UTC Modified: 2004-10-22 22:00 UTC
From: deyv at php dot pl Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.2 OS: windows + 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: deyv at php dot pl
New email:
PHP Version: OS:

 

 [2004-10-22 21:51 UTC] deyv at php dot pl
Description:
------------
In the __destructor all changes in the 
$_SESSION array was not saved.


In the php 5.1 it's work corectly. 

Reproduce code:
---------------
session_start();

class test
{
 	function __construct()
 	{
        echo '<br />__construct <br />'; 	
 		var_dump( $_SESSION );
 		
 		if( empty( $_SESSION['iForConstruct'] ) ) 
 		{ 			
 			$_SESSION['iForConstruct'] = 1;
 			$_SESSION['iForDestruct']  = 1;
 		}
 		$_SESSION['iForConstruct']++;
 	}
 	 	
 	function __destruct()
 	{
 		echo '<br />__destruct'; 		
 		$_SESSION['iForDestruct'] ++;  	
 	}	
}
$test = new test();

Expected result:
----------------
In the all refresh we expect incrementing the values of $_SESSION['iForConstruct'] and $_SESSION['iForDestruct']
for all refresh's

Actual result:
--------------
incrementing only $_SESSION['iForConstruct']

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-22 22:00 UTC] derick@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

The session is ended before destructors are run.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 09:01:33 2024 UTC