php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36829 No session data saved after working with $GLOBALS in object
Submitted: 2006-03-23 07:06 UTC Modified: 2006-03-23 09:11 UTC
From: voodoo at mail dot ru Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.1.2 OS: Linux 2.6.15-1.1833_FC4smp
Private report: No CVE-ID: None
 [2006-03-23 07:06 UTC] voodoo at mail dot ru
Description:
------------
No session data saved after working with $GLOBALS in object. In detail, when I put $GLOBALS in class var and try to change session variable, stored in $_SESSION, session variable haven't been changed.
When placing $obj = new test after $_SESSION['test'] increment, it's all seems to be OK.
PHP 5.0.4 (cli) (built: Jul 27 2005 12:29:26)
(couldn't find it in PHP version list)

Reproduce code:
---------------
<?php
session_start();
$obj = new test;
echo $_SESSION['test']++;
class test {
  var $vars;

  function test() {
      foreach ($GLOBALS as $k => $v) {
        $this->vars[$k] = $v;
      }
  }
}
?>

Expected result:
----------------
Increment at each page reload

Actual result:
--------------
no output

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-23 09:11 UTC] tony2001@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC