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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC