I am having a little trouble with my session variables which do not appear to be working correctly. Here is a simplified version of my code:
Code: Select all
<?
session_start();
session_register ("test1");
session_register ("test2");
require 'quote_routines.php';
if (isset($_POST['submit2'])) {
$HTTP_SESSION_VARS["test2"]=$HTTP_POST_VARS['test2'];
echo $HTTP_SESSION_VARS["test1"];
echo $HTTP_SESSION_VARS["test2"];
}
if (isset($_POST['submit1'])) {
$HTTP_SESSION_VARS["test1"]=$HTTP_POST_VARS['test1'];
echo $HTTP_SESSION_VARS["test1"];
procedure2();
}
else{
procedure1();
}
?>The second if meets the condition this time and I copy the posted value into the session variable, I then echo the variable and it outputs the correct data. So far so good.
I then call procedure2 which does exactly the same as procedure1, ie. collects a string. Again this is submitted and this time the first if condition is met.
Again I copy the submitted data into a session variable and then try to output the data from both of the session variables. I only get output for the 2nd newly created, I get nothing for test1.
Any suggestions, the only way I can see to get this towork is to pass the variables as paramaters but I do not want to have to do this and surely this defeats the object of session variables?
Thanks in advance.
Rob.