This article mainly introduces how php uses cookies to save the login user name, including submitting the page and setting the cookie. For more information, see
This article mainly introduces how php uses cookies to save the login user name, including submitting the page and setting the cookie. For more information, see
This example describes how php saves the login user name using cookies. Share it with you for your reference. The details are as follows:
Submit Form page
The Code is as follows:
<? Php
$ User = isset ($ _ COOKIE ['username'])? $ _ COOKIE ['username']: '';
?>
Form information receiving page, and set cookie
The Code is as follows:
<? Php
$ User = $ _ POST ['username'];
If ($ _ POST ['rem ']) {
Setcookie ("username", $ user, time () + 3600*3600*24 );
} Else {
Setcookie ("username", '', time ()-1 );
}
Echo "Logon successful ";
?>
I hope this article will help you with php programming.
,