#30536 [Opn->Bgs]: Can't write to $_SESSION in the __destructor()

From: Date: Fri, 22 Oct 2004 20:00:17 +0000
Subject: #30536 [Opn->Bgs]: Can't write to $_SESSION in the __destructor()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67971@lists.php.net to get a copy of this message
ID: 30536 Updated by: derick@php.net Reported By: deyv at php dot pl -Status: Open +Status: Bogus Bug Type: Session related Operating System: windows + linux PHP Version: 5.0.2 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2004-10-22 21:51:59] 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'] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30536&edit=1

« previous php.bugs (#67971) next »