I stipped the page down to almost nothing and tried it. It didn't work. But that got me to looking at it closer. Found the mistake and just as I expected, it was a stupid mistake by the operator - me!
For anyone else reading this, if you look at the original code I posted, it included the following (see if you can find the error):
$sql_code = "SELECT Password, Level FROM $name_table ";
$sql_code .= "WHERE ID = '$id'";
// testing only
// echo $sql_code . "<br><br>";
$sql_result = mysql_query($sql_code,$name_connect) or die(mysql_error());
$output = mysql_fetch_array($sql_result);
$pwdSQL = $output["Password"];
$lvlSQL = $output["Level"];
// testing only
// echo "sql pwd: '" . $pwdSQL . "'<br>sql lvl: '" . $lvlSQL . "'<br>rows: '" . mysql_num_rows($sql_result) . "'<br>post pwd: '" . $pwd . "'<br>post id: '" . $id . "'<br>";
// set cookie time limit - 180 days
$hold = 60 * 60 * 24 * 180;
if ($pwdSQL == $pwd)
{
// validated user - write cookie and continue
setcookie("user", $id, $hold);
setcookie("level", "$lvlSQL", $hold);
setcookie("authorized", "yes", $hold);
header("Location: [url]http://www.mokenahickorycreek.com/SQL_Staff.php[/url]");
exit;
}
else
{
setcookie("user", "guest", $hold);
setcookie("level", "0", $hold);
setcookie("authorized", "no", $hold);
header("Location: [url]http://www.mokenahickorycreek.com/index.php[/url]");
exit;
}
}
else
{
// testing only
// echo "post variables id: '" . $_POST["id"] . "'<br>pwd: '" . $_POST["pwd"] . "'<br>post pwd: '" . $pwd . "'<br>";
}
OK, give up? The variable to set the time limit was missing one important part. The time to now to which the future time was to be added. It was always timed out as soon as it was written. The system may not have even written it when it saw the expiration date.
Thanks for your (and everyone elses) help. I might have flailed around for every. Or more probably I would have dumped cookies and just checked the database each time. But that wouldn't have answered the question even if it worked around it.