PHP login remember password implementation ideas. Copy the code on the form page: formactionlogin. phpmethodpost username inputtypetextnameusernamebr password inputtypetextnamepasswordbr remember password input form page
The code is as follows:
User information
Session_start ();
Function p ($ arr ){
Echo"
";
print_r($arr);
echo "
";
}
P ($ _ SESSION );
P ($ _ COOKIE );
?>
Logon page
The code is as follows:
Function p ($ arr ){
Echo"
";
print_r($arr);
echo "
";
}
Session_start ();
// P ($ _ POST );
$ _ SESSION ['username'] =_ _ POST ['username'];
$ _ SESSION ['password'] =$ _ POST ['password'];
If ($ _ POST ['jizhu']) {
Setcookie ('username', $ _ POST ['username'], time () + 60 );
Setcookie ('password', $ _ POST ['password'], time () + 60 );
}
Header ("location: form. php ");
User information page
The code is as follows:
Session_start ();
Echo "first close the browser, try to access form. php, and then click ";
P ($ _ SESSION );
P ($ _ COOKIE );
If (empty ($ _ SESSION ['username']) {
If (empty ($ _ COOKIE ['username']) {
Echo "log on first"; exit;
} Else {
$ _ SESSION ['username'] = $ _ COOKIE ['username'];
}
}
Function p ($ arr ){
Echo"
";
print_r($arr);
echo "
";
}
?>
2131231231
Modify information
Launch
Launch page
The code is as follows:
Session_start ();
Unset ($ _ SESSION ['username']);
Unset ($ _ SESSION ['password']);
Setcookie ('username', '', 0 );
Setcookie ('password', '', 0 );
Header ("location: form. php ");
?>
Modify user information page
The code is as follows:
Session_start ();
If (empty ($ _ SESSION ['username']) {
Echo "log on first ";
} Else {
Echo "Here is information ";
}
?>
The authorization code is as follows: form action = "login. php "method =" post "user name input type =" text "name =" username "br password input type =" text "name =" password "br remember password input...