Home  >  Article  >  Backend Development  >  PHP uses session for login verification

PHP uses session for login verification

王林
王林forward
2020-01-23 19:32:273602browse

PHP uses session for login verification

1. Overview

Back-end language: php (native php is used, no framework is introduced)

Front-end style: Bootstrap

Main functions: Basic administrator functions. Ordinary users need to use administrators for unified management. Ordinary users can view statistical data, and administrator users can only log in to the administrator center to manage users.

(Related learning video tutorial sharing: php video tutorial)

2. Session usage

a. After successful login, you need to create and record session

InitMySQL();
    $level = SelectUserLevel($helper,$name,$password);
    if($level != -1)
    {
        $result = $level;
        session_start();
        $_SESSION["user"] = true;
        $_SESSION["name"]=$name;
        $_SESSION["pwd"]=$password;
    }
    echo $result;
?>

b. Other functional modules use the specific method of session to write a general php. Other modules first call this php to determine whether to log in before calling.

Recommended related articles and tutorials: php tutorial

Recommended related articles: The most comprehensive collection of js interview questions in 2020 (up to date)

The above is the detailed content of PHP uses session for login verification. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete