I have this small PHP script:
<?php
session_start();
$var = array();
$var['key'] = 'Var -> Key';
if ($_GET['set']) {
$_SESSION = array();
$_SESSION['var'] = 'Session -> Var';
}
print_r($_SESSION);
?>
I would expect it to return this, for set=0 and set=1:
Array
(
[var] => Session -> Var
)
However it returns this for set=0 (after set=1 of course):
Array
(
[var] => Array
(
[key] => Var -> Key
)
)
Have a look yourselfe over here: http://dev.gruppenunterkuenfte.de/index_test.php?set=1
What 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.