php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32168 A recovering of variable while using reference to $_SESSION
Submitted: 2005-03-03 11:42 UTC Modified: 2005-03-17 13:28 UTC
From: KRomas at goldentele dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4CVS-2005-03-09 OS: Linux
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: KRomas at goldentele dot com
New email:
PHP Version: OS:

 

 [2005-03-03 11:42 UTC] KRomas at goldentele dot com
Description:
------------
If we erase the $_SESSION and then make the reference to some session variable X, the value of X is recovering, ie not erased.

Configure Command:
./configure' '--prefix=/usr/local/apache' '--with-config-file-path=/usr/local/Zend/etc' '--enable-track-vars' '--with-apxs=/usr/local/apache/bin/apxs' '--with-gd' '--with-oci8=/oracle/8.1.7' '--enable-trans-sid' '--enable-sigchild' '--with-zlib' '--enable-sockets' '--with-zlib-dir=/usr/local/include' '--with-iconv' '--with-iconv-dir=/usr/local' '--disable-debug' '--with-sybase-ct=/usr/local/freetds'

Reproduce code:
---------------
Please run folow files in order:
1.php
<?
	session_start();
	
	$_SESSION	=	Array();
	$_SESSION['a']['b']	=	1;
	
	echo	'<PRE>';
	var_dump($_SESSION);
?>

2.php
<?
	session_start();

	$_SESSION	=	Array();
	//unset($_SESSION['a']);
	//session_unregister('a');

	//$val		=	$_SESSION['a'];
	$val		=	& $_SESSION['a'];

	echo '<PRE>';
	var_dump($_SESSION);
?>

3.php
<?
	session_start();
	
	echo '<PRE>';
	var_dump($_SESSION);
?>

Expected result:
----------------
array(1) {
  ["a"]=>
  &NULL
}

Actual result:
--------------
array(1) {
  ["a"]=>
  &array(1) {
    ["b"]=>
    int(1)
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-03 12:30 UTC] KRomas at goldentele dot com
There is a result for 3-rd file
 [2005-03-04 14:42 UTC] KRomas at goldentele dot com
Sorry, Win-version 4.3.10 hasn't this bug, but Linux-version 4.3.10!
 [2005-03-09 08:31 UTC] KRomas at goldentele dot com
For now PHP Version is 4.3.11-dev (Linux) and there is the same error:
array(1) {
  ["a"]=>
  &array(1) {
    ["b"]=>
    int(1)
  }
}
Win-version work perfectly however:
array(1) {
  ["a"]=>
  NULL
}
 [2005-03-09 22:07 UTC] sniper@php.net
Are you sure you're trying same PHP version in Windows?
(before installing the snapshot delete EVERY file even remotely related to PHP..)

 [2005-03-10 10:29 UTC] KRomas at goldentele dot com
Yes.
I have downloaded php4-win32-STABLE-latest.zip, completely removed d:\Program Files\php\, got message "The requested URL /php/php.exe/3.php was not found on this server", extracted  archive to d:\Program Files\php\, executed script and got right response in contrast to Linux-version.
---------- phpinfo:
PHP Version 4.3.11-dev
System  Windows NT 5.0 build 2195  
Zend Engine v1.3.0
SERVER_SOFTWARE  Apache/1.3.33 (Win32)
 [2005-03-11 08:23 UTC] KRomas at goldentele dot com
Have you the same result
array(1) {
  ["a"]=>
  &array(1) {
    ["b"]=>
    int(1)
  }
}
on Linux-version of PHP?
 [2005-03-14 21:55 UTC] sniper@php.net
I'm getting the expected result with Linux. Check your php.ini settings, the ones important are: register_globals=off, and all the session.bug_compat* 

 [2005-03-17 13:28 UTC] KRomas at goldentele dot com
There is register_globals=on on my system. I understand this as value has recovered from global variable. But why recovering not complete if I replace 
$val		=	& $_SESSION['a'];
on
$val		=	$_SESSION['a'];
?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC