Hi,
This is the first time I use sessions, and I can't figure out why it doesnt work. I have 2 scripts, login.php and view.php. A user enters a password in login.php, which is saves in $SESSION['password']. In view.php, $SESSION['password'] is checked again. This doesnt seem to work, I keep getting a bad password error. Check below for the important parts of both scripts.
login.php:
if(!check_pass($password)) {
echo "<b>Wrong password, please go back and try again</b>";
} else {
$_SESSION['password'] = $password;
print_classes();
}
view.php:
function check_sess($sess_pass) {
if($sess_pass == "password") {
return 1;
} else {
return 0;
}
} //end check_sess
.
.
.
.
if(!check_sess($sess_pass)) {
echo "<b><a href=login.php>Login here (bad password)</a></b>";
} else {
$class = $_GET['class'];
display($class);
}
I keep getting "Login here (bad password)" so I assume the password isnt passed properly through the session. Both pages have sessions initialized properly with the following, so thats not the problem:
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>