php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24908 Unexpected $_SESSION value in __destruct function
Submitted: 2003-08-01 12:33 UTC Modified: 2004-01-27 16:21 UTC
From: itotakas at msu dot edu Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-11-29 OS: *
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: itotakas at msu dot edu
New email:
PHP Version: OS:

 

 [2003-08-01 12:33 UTC] itotakas at msu dot edu
Description:
------------
$_SESSION variable should be "array" and "super global".
However, within the __destrunct function, $_SESSION changes its value to the reference to the class which implements __destruct function.

[Example]
<?
  session_start();
  $_SESSION["test"] = "test string";

  class test {
      function __destruct()
      {
          // $_SESSION = $this !?
          print_r($_SESSION);
      }
  }

  $test = new test;
?>

[Expected result]
Array ( [test] => test string )

[Actual result]
test Object ( )

Reproduce code:
---------------
<?
  session_start();
  $_SESSION["test"] = "test string";

  class test {
      function __destruct()
      {
          // $_SESSION = $this !?
          print_r($_SESSION);
      }
  }

  $test = new test;
?>

Expected result:
----------------
Array ( [test] => test string )

Actual result:
--------------
test Object ( )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-10 22:28 UTC] iliaa@php.net
The problem will occur when any super global is used from within __destruct.
Here is a simpler example:
<?php
class test { function __destruct() { print_r($_ENV); } }
$test = new test();
?>

 [2003-08-11 14:11 UTC] helly@php.net
Also see #24914
 [2004-01-27 16:21 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Seems to be fixed.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Sep 05 20:00:01 2025 UTC