Session variables again
Posted: Thu Jul 17, 2003 7:55 pm
Must be sounding cliche or dumb asking about Php session variables (tons must have brought up the problem).
Running Apache2/php 4.3.2 experimental/windows xp sp1
I have register_globals turned on. I still had problems with creating session variables. So I used the alternate method suggested (with globals turned off) and I am still not able to propagate session variables across different php pages. Can someone tell me what I am doing wrong (register_globals is still turned ON):
Form.html (I accept a simple password)
==========================
<html>
<body>
<form name="form1" method="post" action="login.php">
<p><input type=password name=password>
<p><input type=submit name=submit value=Submit>
</form>
</body>
</html>
Login.php (get the password and sets a session variable
====================================
<?
session_start();
$password = $_POST['password'];
echo "<p>" . $password;
$_SESSION["password"] = $password;
//session_register("password"); //Tried this one too, no luck
echo "<p>" . $_SESSION["password"]; //works OK
?>
admin.php (another php code trying to get the password)
====================================
<?
session_start();
$password = $_SESSION["password"];
echo "<p>" . $password; //Nothing is printed out
?>
Running Apache2/php 4.3.2 experimental/windows xp sp1
I have register_globals turned on. I still had problems with creating session variables. So I used the alternate method suggested (with globals turned off) and I am still not able to propagate session variables across different php pages. Can someone tell me what I am doing wrong (register_globals is still turned ON):
Form.html (I accept a simple password)
==========================
<html>
<body>
<form name="form1" method="post" action="login.php">
<p><input type=password name=password>
<p><input type=submit name=submit value=Submit>
</form>
</body>
</html>
Login.php (get the password and sets a session variable
====================================
<?
session_start();
$password = $_POST['password'];
echo "<p>" . $password;
$_SESSION["password"] = $password;
//session_register("password"); //Tried this one too, no luck
echo "<p>" . $_SESSION["password"]; //works OK
?>
admin.php (another php code trying to get the password)
====================================
<?
session_start();
$password = $_SESSION["password"];
echo "<p>" . $password; //Nothing is printed out
?>