Strange PHP Session behaviour. PHP overwrites $_SESSION['var'] with $var

AuroraStorm

New Member
I have this small PHP script:\[code\]<?phpsession_start();$var = array();$var['key'] = 'Var -> Key';if ($_GET['set']) { $_SESSION = array(); $_SESSION['var'] = 'Session -> Var';}print_r($_SESSION);?>\[/code\]I would expect it to return this, for set=0 and set=1:\[code\]Array( [var] => Session -> Var)\[/code\]However it returns this for set=0 (after set=1 of course):\[code\]Array( [var] => Array ( [key] => Var -> Key ))\[/code\]Have a look yourselfe over here:http://dev.gruppenunterkuenfte.de/index_test.php?set=1What seams to happen is that $_SESSION['var'] gets replaced by $var.But only after the next page load.Any idea why?I can switch my PHP version in my hosters admin interface and I tried 5.2.11, 5.3.2 and 4.4.8.Is it a setting I can change in PHP, so it will not overwrite Session Variables?Cause I don't have this issue on another server.There seams to be some kind of setting to make PHP write $var in $_SESSION['var'], if $_SESSION['var'] is defined.
 
Back
Top