php uses cookies to save user name instances for user login, cookie user login
The example in this article describes how PHP uses cookies to save the user name of the user's login. Share it with everyone for your reference. The specific implementation method is as follows:
User login file: login.php
Copy code The code is as follows:
User login
function getCookieUsername(){
if(empty($_COOKIE['username'])){
return "";
}else{
Return $_COOKIE['username'];
}
}
?>
Backend file: admin.php
Copy code The code is as follows:
if(!empty($_POST['sub']) && $_POST['username']=="admin"){
echo "Welcome".$_POST['username']." Login successful";
if(!empty($_POST['yes'])){
setCookie("username",$_POST['username'],time()+3600*24*30);
}else{
setCookie("username","",time()-10);
}
}else{
echo "Your account is wrong, please re-enter
";
}
echo "
Return to login page";
?>
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/947914.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/947914.htmlTechArticlephp uses cookies to save user login examples, cookie user login This article tells the example of php using cookies to save user logins username method. Share it with everyone for your reference. ...