Posted by Michael Fesser on 01/14/08 13:28
..oO(Peter Pei)
>What an idiot! He tested and they are related - that's a fact. How many
>times I told you in other threads the same thing?
How many times you were told that you're wrong? $_SESSION['foo'] and
$foo are only related if register_globals is turned on. A simple test:
<?php
session_start();
if (isset($_GET['show'])) {
print '<pre>';
print_r($_SESSION);
var_dump($foo);
var_dump($bar);
print '</pre>';
} else {
$_SESSION['foo'] = 23;
$_SESSION['bar'] = 42;
}
print "<a href='{$_SERVER['PHP_SELF']}?show'>next</a>";
?>
After calling the script and clicking the link, the result with
register_globals = ON will be:
Array
(
[foo] => 23
[bar] => 42
)
int(23)
int(42)
This is what the OP got. Now the same thing with register_globals = OFF:
Array
(
[foo] => 23
[bar] => 42
)
Notice: Undefined variable: foo in ...
NULL
Notice: Undefined variable: bar in ...
NULL
This is how it should be on a properly configured system.
Micha
Navigation:
[Reply to this message]
|