Heres what I've narrowed it down to... seems to work alright, even though I know I opened up a huge security risk.... this page is just for my friends though
if (isset($_COOKIE['saved_user']) && $_COOKIE['saved_user'] != "off") {
//checks if they are saved on this computer
if (!isset($_SESSION['valid_user'])) {
//if this is their first visit, but they are saved
$username = $_COOKIE['saved_user'];
$_SESSION['valid_user'] = $username;
}
$username = $_SESSION['valid_user'];
$cookiefourmonths = time() + (60 * 60 * 24 * 31 * 4);
setcookie ("saved_user", "$username", $cookiefourmonths); //sets the saved cookie +4 months
$permlog = "on";
} else {
$permlog = "off";
}
if ($_GET[action] == permlogoff) {
$negcookiefourmonths = time() - (60 * 60 * 24 * 31 * 4);
setcookie ("saved_user", "off", $negcookiefourmonths);
$permlog = "off";
}
if ($_GET[action] == permlogon) {
$username = $_SESSION['valid_user'];
$cookiefourmonths = time() + (60 * 60 * 24 * 31 * 4);
setcookie ("saved_user", "$username", $cookiefourmonths);
$permlog = "on";
}
the $permlog variable is for the user_options page... but my main problem was I was setting the cookie after the other two expressions, and correct me if I'm wrong but the cookies don't get stored untill the next page? Or the end of the page? I think thats what was messing me up.