#47448 [Opn->Csd]: corrupted referencing with $_SESSION

From: Date: Thu, 19 Feb 2009 10:23:17 +0000
Subject: #47448 [Opn->Csd]: corrupted referencing with $_SESSION
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133994@lists.php.net to get a copy of this message
ID: 47448 User updated by: rafael at freshsite dot de Reported By: rafael at freshsite dot de -Status: Open +Status: Closed Bug Type: Session related Operating System: Mac OSX PHP Version: 5.2.9RC2 New Comment: Happens, when register_globals is ON. Set it OFF! Previous Comments: ------------------------------------------------------------------------ [2009-02-19 10:16:53] rafael at freshsite dot de Edit: moved to "Session related" ------------------------------------------------------------------------ [2009-02-19 10:06:20] 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) } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47448&edit=1

« previous php.bugs (#133994) next »