php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38833 $_SESSION looses its ability to set session variables
Submitted: 2006-09-14 17:40 UTC Modified: 2006-09-14 18:04 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:4 (100.0%)
From: php at arcannon dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5CVS-2006-09-14 (CVS) OS: Fedora Core 5
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: php at arcannon dot com
New email:
PHP Version: OS:

 

 [2006-09-14 17:40 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-14 17:48 UTC] 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 18:04 UTC] tony2001@php.net
$_SESSION looses it's "magical" behaviour when assigned to any variable.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 09:01:27 2025 UTC