Jump to content

Recommended Posts

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!

Edited by Amster
Link to comment
https://forums.phpfreaks.com/topic/269557-help-with-login-script/
Share on other sites

You say it just redirects you to login page with no errors... Try commenting out all header() lines, and put error messages in their place instead.

 

Then post back here and tell us what the error is.

 

//error message
echo "Error: ".mysql_error();

Edited by White_Lily

In the posted code, the header() is unconditional; it will redirect regardless of what happens elsewhere in the script. An exception may be if an error message is generated. If that is happening, the header() call would generate a 'headers already sent' error instead of redirecting.

Edited by Pikachu2000
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.