PHP uses session for login verification

王林
Release: 2023-04-08 09:54:01
forward
3586 people have browsed it

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;
?>
Copy after login

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.

Copy after login

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!