php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47448 corrupted referencing with $_SESSION
Submitted: 2009-02-19 10:06 UTC Modified: 2009-02-19 10:23 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rafael at freshsite dot de Assigned:
Status: Closed Package: Session related
PHP Version: 5.2.9RC2 OS: Mac OSX
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: rafael at freshsite dot de
New email:
PHP Version: OS:

 

 [2009-02-19 10:06 UTC] rafael at freshsite dot de
Description:
------------
$_SESSION['key'] (key) is changing when using $key in context.

Seems only happening on Mac OSX, because the "expected result" (below) comes from linux php, the "actual result" comes out of a Mac machine.

Reproduce code:
---------------
<?php
session_start();
class test{
	public function get_data(){
		$tmp = array(
				array('isadmin'=>1, 'test'=>0)	
			);
		$_SESSION['user'] = $tmp[0];
	}
}

$tester = new test();
$tester->get_data();
var_dump($_SESSION);
/*
 * Output (correct):
  array(1) {
  ["user"]=>
  &array(2) {
    ["isadmin"]=>
    int(1)
    ["test"]=>
    int(0)
  }
}
  
 */
$user = array('isadmin'=>0, "test"=>1);
var_dump($_SESSION);

/*
 * Output (NOT correct):
 * 
array(1) {
  ["user"]=>
  &array(2) {
    ["isadmin"]=>
    int(0)
    ["test"]=>
    int(1)
  }
}
 */
?>

Expected result:
----------------
array(1) {
  ["user"]=>
  array(2) {
    ["isadmin"]=>
    int(1)
    ["test"]=>
    int(0)
  }
}
array(1) {
  ["user"]=>
  array(2) {
    ["isadmin"]=>
    int(1)
    ["test"]=>
    int(0)
  }
}


Actual result:
--------------
array(1) {
  ["user"]=>
  &array(2) {
    ["isadmin"]=>
    int(1)
    ["test"]=>
    int(0)
  }
}
array(1) {
  ["user"]=>
  &array(2) {
    ["admin"]=>
    int(0)
    ["test"]=>
    int(1)
  }
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-19 10:16 UTC] rafael at freshsite dot de
Edit: moved to "Session related"
 [2009-02-19 10:23 UTC] rafael at freshsite dot de
Happens, when register_globals is ON.
Set it OFF!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 17:01:28 2025 UTC