User: User:

Home  >  Article  >  Backend Development  >  PHP cookie operation implements code login

PHP cookie operation implements code login

WBOY
WBOYOriginal
2016-07-29 08:44:021133browse

The first file login_frm.php is the login window
code

Copy the code The code is as follows:








User:





The second file login.php is to handle login

Copy code The code is as follows:


if($_POST['username'] = 'admin')
{
setcookie('haha','gogo');
header( "location:index.php");
}
?>


Third file index.php and see the effect again

Copy the code The code is as follows:


if( $_COOKIE['haha'] == 'gogogo')
{
echo $_COOKIE['haha'];
echo 'You have set a cookie';
}
else
{
echo 'You have not set a cookie';
}
?>


For more basic information, please refer to PHP Cookies

The above introduces the operation of php cookie to realize code login, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn