This is the basic functionality thats giving me problems. There are 2 webpages involved : enter.php and secure/execute.php. enter.php sets a few session variables and secure/execute.php checks them. Please note that session.use_cookies = 0
enter.php
<?PHP
session_start();
$username = $POST["name"];
$password = md5($POST["password"]);
$_SESSION["test_session"] = "this is a test";
if(($username == "USER") && ($password == md5("PASSWORD")))
{
session_register("uname");
$uname = $username;
session_encode();
$_SESSION["user"] = $username;
header("Location: secure/execute.php");
}
?>
<form name="enter" method="post" action="<?php echo $PHP_SELF; ?>">
<?PHP echo $error_message; ?>
<input name="id" type="hidden" value="set">
Name: <input name="name" type="text" size="20" value="<?PHP echo $username; ?>"><br>
Password:<input name="password" type="password" size="20" maxlength="20" value="">
<input type="submit" name="nsubmit" value="LOGIN">
</form>
secure/execute.php
<?PHP
// session start
session_start();
// is set session variable?
echo "session test value = " . $SESSION["test_session"] . "<br>";
if (!isset($SESSION["user"]))
// recall the enter page
{
header("Location: ../enter.php");
exit;
}
else
{
$usr = $_SESSION["user"];
print "session user is set<br>usr := $usr<br>";
}
?>