Jump to content

Archived

This topic is now archived and is closed to further replies.

aviatorisu

Login Script utilizing sessions...

Recommended Posts

Hypothetically:

If I were using a login script that uses sessions, and for logging in, there is a script that checks for errors such as wrong password, username, etc...what would need to happen to clear out the errors so a person could login correctly? Would such a script use the session to 'record' the error so that there would need to be some kind of destroy command given to wipe the memory of there being an error???

I'm at my wits end trying to figure this problem out.

~Z~

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]what would need to happen to clear out the errors so a person could login correctly?[/quote]
Simply dont save any values to the session untill they satisfy authentication.

Share this post


Link to post
Share on other sites
i use session to pass error messages back to the login or register page so basically I do this

[code]
if($_SESSION['send'] == "no")
{
    print $_SESSION['error'];
    require_once('templates/login_form.php');
    unset($_SESSION['send']);
}
else
{
    require_once('templates/login_form.php');
}
?>

[/code]

That way if there is no $_SESSION['send'] to say what to do with the form I load my form, however if my script sees an error I give a variable $send = "no"; then an error message variable $msg .= "There has been an error";

Once all the messages are gathered I set my session variables
$_SESSION['send'] = $send;
$_SESSION['error'] = $msg;

This then gets passed back to the form page explains the error and gives them a new chance.

The unset($_SESSION['send']) is so after it displays the error, my script knows to look for a new variable on the next load.

Share this post


Link to post
Share on other sites

×

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.