Php $ _ SESSION member login instance sharing

Source: Internet
Author: User
Tags tutorialspoint
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.