Home >Backend Development >PHP Tutorial >Learning example of setting session value and cookies in php_PHP tutorial
Step one: First write a login page and a content page locally (you can only enter after logging in). The code is roughly as follows:
The following is login.php, which is used to request login. Parameters are passed through post. If the login is successful, the session will be registered.
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == 'admin' && $password == 'admin') {
$_SESSION['username'] = $username;
echo "";
} else {
; ;body>