[SOLVED] Session variables...
Posted: Fri Apr 01, 2005 8:05 am
Hi I am having some trouble with session variables.
I have a form as follows:
I am then intialising session variables in the index.php script based on data passed with the above form:
Everything works great, I have tested this by echoing the session variables and they are outputting the correct data.
Now my index.php script calls an i-frame as follows:
However if I now try to access the session variables in the i-frame script main.php as follows....
... they appear to be empty.
What am I doing wrong, are session variable not global in scope?
Thanks in advance.
Rob.
I have a form as follows:
Code: Select all
<form method="POST" action="../index.php">
<tr><td>Account No.:</td><td><input type="text" size="15" name="username"></td></tr>
<tr><td>Password:</td><td><input type="text" size="15" name="password"></td></tr>
<input class=button type="submit" value="Submit" name="submit">
</form>Code: Select all
<?
session_start();
session_register ("username");
session_register ("password");
if(!$HTTP_SESSION_VARS["username"]){
$HTTP_SESSION_VARS["username"]=$HTTP_POST_VARS['username'];
}
if(!$HTTP_SESSION_VARS["password"]){
$HTTP_SESSION_VARS["password"]=$HTTP_POST_VARS['password'];
}
?>Now my index.php script calls an i-frame as follows:
Code: Select all
<iframe name=main src="main.php" width="581" height="354" scrolling=auto></iframe>However if I now try to access the session variables in the i-frame script main.php as follows....
Code: Select all
echo $HTTP_SESSION_VARS["username"];What am I doing wrong, are session variable not global in scope?
Thanks in advance.
Rob.