Home  >  Article  >  Backend Development  >  Cookie operation example in php_PHP tutorial

Cookie operation example in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:22:34734browse

Cookie operation example in php

I made an example of cookie operation. The first file login_frm.PHP is the login window.

Code 1

 2

 3

 4

 5

 6

 10

 11

The second file login.php is used to handle login

 1

 2 if($_POST['username'] = 'admin')

 3 {

 4 setcookie('haha','gogo');

 5 header("location:index.php");

 6}

 7 ?>

Let’s take a look at the effect of the third file index.php

 1

 2 if($_COOKIE['haha'] == 'gogogo')

 3 {

 4

 5 echo $_COOKIE['haha'];

 6 echo 'You have set a cookie';

 7}

 8 else

 9 {

 10 echo 'You have not set cookies';

 11}

 12 ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/847198.htmlTechArticle An example of cookie operation is made in php. The first file login_frm.PHP is the login window. . Code 1 2 3 4 5 6 10 11 The second file login.php is to handle login...
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