This article describes in detail the php $ _ SESSION member logon instance, which has some reference value, if you are interested, you can refer to the php member login module, which is a simple module in website development. this example provides a simple reference for php beginners, the logic of this solution is to be understood by the Reader, edited, and thought upon by the reader.
Login. php file
<?php ob_start(); session_start();?><? // error_reporting(E_ALL); // ini_set("display_errors", 1);?> Tutorialspoint.com
Enter Username and Password <?php $msg = ''; if (isset($_POST['login']) && !empty($_POST['username']) && !empty($_POST['password'])) { if ($_POST['username'] == 'tutorialspoint' && $_POST['password'] == '1234') { $_SESSION['valid'] = true; $_SESSION['timeout'] = time(); $_SESSION['username'] = 'tutorialspoint'; echo 'You have entered valid use name and password'; } else { $msg = 'Wrong username or password'; } } ?>
Click here to clean Session.
Logout. php file
<?php session_start(); unset($_SESSION["username"]); unset($_SESSION["password"]); echo 'You have cleaned session'; header('Refresh: 2; URL=login.php');?>
The above is all the content of this article, hoping to help you learn.