After successful login, it is found that setcookie takes effect locally. The cookie is stored, and the key value is encrypted using the md5 function.
The cookie value can be retrieved through the $_COOKIE array.
The session is generally stored on the server side.
The session must be opened before use, session_destroy will destroy the session so that it cannot be used in other files, and the session information is also stored in the corresponding $_SESSION array.
You can see the session information just stored.
Since the session_destroy function was called just now, the session information is not available on this page.
Comment out this function, and reload the session.php page, and then enter the session2.php page.
You can see that the session information stored in the session.php page is retrieved on the session2.php page
You can use the unset function to destroy a specified key value in the session.
You can see that the username key and the corresponding value have been destroyed.
Through cookie and session, user login and session control can be realized flexibly.