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 ?>