I start off my page with the following code:
// Check for Existing Cookie
if (!isset($login)) {
setcookie("login","false",time()+1400);
}
This is at the very top of the page and I'm using it to automatically set login to false, assuming it's not set to anything.
Then, when the user uses the login form, I use the following code:
$username = $POST['username'];
$password = $POST['password'];
$connection = mysql_connect($database,$dbuser,$dbpass) or die ("The database server is down! Please contact the administrator.");
$db = mysql_select_db($dbname,$connection) or die ("Sorry, but we were unable to access the database. Please contact the administrator.");
$login = mysql_query("SELECT userid FROM users WHERE username = '$username' AND pword = '$password'",$connection) or die ("Sorry, but we were unable to verify your login. Please contract the administrator.");
$numrows = mysql_num_rows($login );
if ($numrows > 0) {
setcookie("login","true",time()+1400);
$location = "http://www.domain.com/member";
header("Location: $location");
}
However, it doesn't seem to set login to true. I've tried called and checking it many different ways, but the cookie never gets set to true. I've checked the query and the number of rows to make sure it evaluates properly and it does. Any clue what could be causing this?