To determine the user login is mainly divided into several processes, the first step is to save the data to the session after the user has successfully logged in, and then when the user access needs to login user rights to determine whether the session is empty, if not the login success. Let's look at an example
To determine the user login is mainly divided into several processes, the first step is to save the data to the session after the user has successfully logged in, and then when the user access needs to login user rights to determine whether the session is empty, if not the login success. Let's look at an example
Session_Start ();
if (GetConfig ("Chatroom_admin") ==$_post["username"]&&getconfig ("Chatroom_adminpassword") ==md5 ($_post[" Password "]))
{
Login successful, register session
Session_register ("Administrator");
if (Isset ($_session["Hack_num"))
{
Session_unregister ("Hack_num");
}
$_session["Administrator"] = "yes";
Header ("location:main.php");
Exit
}
Else
{
if ($_session["Hack_num"]== "")
{
Session_register ("Hack_num");
$_session["Hack_num"] = 1;
}
Else
{
$_session["Hack_num"] + +;
}
Header ("Location:.. /notice.php?id= ". Admin_login_lost);
Exit
}
?>
See the Red No, there is the user login successfully saved to the session[' Hack_num ' face.
This page first determines whether the user is logged in correctly, or, if not logged in, goes to the login page.
Session_Start ();
if ((! $user _id) or (! $user _array[hack_num]) or (! $user _array[hack_num])) {
Header ("location:login.php3");
}
?>
The above code is used to determine whether session[' Hack_num ' has a value, there is a successful login.
This site original reprint annotated source http://www.bKjia.c0m/phper/php.html
http://www.bkjia.com/PHPjc/632039.html www.bkjia.com true http://www.bkjia.com/PHPjc/632039.html techarticle To determine the user login is mainly divided into several processes, the first step is to save the data to the session after the user has successfully logged in, and then when the user access needs to login user rights to determine whether the session ...