I am using the php-login script. Everything has been working fine but suddenly now when I try logging in with an account (called user1) that has always worked previously, it simply redirects me to the login page. It does not error, it just redirects. Although if I try another account (user 2), I login normally but this one account (user 1) just does not seem to not want to login and just keeps redirecting me back when I try logging in.
Also, the script only works if I have the “Remember Me” box checked. I have a feeling that it is an issue with cookies, I have taken a code snippet here:
session_start();
session_regenerate_id (true); //prevent against session fixation attacks.
// this sets variables in the session
$_SESSION['user_id']= $id;
$_SESSION['user_name'] = $full_name;
$_SESSION['user_level'] = $user_level;
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
//update the timestamp and key for cookie
$stamp = time();
$ckey = GenKey();
mysql_query("update users set `ctime`='$stamp', `ckey` = '$ckey' where id='$id'") or die(mysql_error());
//set a cookie
if(isset($_POST['remember'])){
setcookie("user_id", $_SESSION['user_id'], time()+60*60*24*365, "/");
setcookie("user_key", sha1($ckey), time()+60*60*24*365, "/");
setcookie("user_name",$_SESSION['user_name'], time()+60*60*24*365, "/");
}
header("Location: myaccount.php");
Although, it may be other things. For further reference, the script I am using is from here: http://php-login-script.com
Thanks!