Forum Moderators: coopster
When using $_SESSION it's a good idea to separate out your variables and don't assume that it's being done for you.
Consider this:
----
$my_variable = $_POST['my_variable'];
session_start();
$_SESSION['my_variable'] = $my_variable;
----
This isn't going to work too well as PHP is going to treat $my_variable, $_POST['my_variable'], and $_SESSION['my_variable'] potentially as one entity - not 3.
Simply by moving the session_start(); causes different results.
So if you want to use POST to grab the initial value, then a variable to handle that value on that specific page and then SESSION to move it to the next page - it's probably better that you define each variable name specific to it's function.
So this is much better
-------
$my_variable_LOCAL = $_POST['my_variable_POST'];
session_start();
$_SESSION['my_variable_SESSION'] = $my_variable_LOCAL;
-------
Doing things this way makes it much work out what's going on.
You can then grab the SESSION back up and write it into your LOCAL variable without the confusion that I've just been through because I assumed that $_SESSION['my_variable'] and $my_variable were different things.
It's a basic point - but worth stating.
If I've just got that completely wrong btw - please let me know.
Cheers.
The behavior you describe should only be a problem with register globals [us2.php.net] turned on. It is recommended for security reasons that register globals be turned off, and newer versions of PHP come with it set to off by default.