#38833 [Opn->Bgs]: $_SESSION looses its ability to set session variables

From: Date: Thu, 14 Sep 2006 18:04:42 +0000
Subject: #38833 [Opn->Bgs]: $_SESSION looses its ability to set session variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102199@lists.php.net to get a copy of this message
ID: 38833 Updated by: tony2001@php.net Reported By: php at arcannon dot com -Status: Open +Status: Bogus Bug Type: Session related Operating System: Fedora Core 5 PHP Version: 5CVS-2006-09-14 (CVS) New Comment: $_SESSION looses it's "magical" behaviour when assigned to any variable. Previous Comments: ------------------------------------------------------------------------ [2006-09-14 17:48:43] sp0n9e at gmail dot com Also does not work with register_long_arrays <?php session_start(); echo session_id()."<br />"; if(!isset($_SESSION['foo'])) $_SESSION['foo'] = 0; $foo = $_SESSION; //works perfectly when this statement is commented $_SESSION['foo']++; echo $_SESSION['foo']; ?> ------------------------------------------------------------------------ [2006-09-14 17:40:41] php at arcannon dot com Description: ------------ $_SESSION looses its ability to set session variables when I do $anythinghere = $_SESSION; This only happens when register_long_arrays = Off Reproduce code: --------------- <? // Bug with Sessions ? // PHP Version 5.1.5 // Operating System: Fedora Core 5 // Only happens when register_long_arrays = Off session_start(); echo "session_id: ".session_id()."<br />"; if(!array_key_exists('counter',$_SESSION)) { $_SESSION['counter'] = 0; } $anythinghere = $_SESSION; echo $_SESSION['counter']; // Play with commenting out these 2 lines and refreshing your page. // $anythinghere['counter']++; $_SESSION['counter']++; ?> Expected result: ---------------- I expect that the session counter to increment on a page reload, but it does not. Actual result: -------------- The session counter does not increment. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38833&edit=1

« previous php.bugs (#102199) next »