Home > Backend Development > PHP Problem > How to implement non-login jump in php

How to implement non-login jump in php

藏色散人
Release: 2023-03-08 15:56:02
Original
2478 people have browsed it

php method to implement non-login jump: first open the corresponding PHP file; then determine whether the session exists; finally use the "if (!$_SESSION['xxx']){}" method to determine the jump to Just go to the login page.

How to implement non-login jump in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php implementation: go to the login page when not logged in

Determine whether the session exists. If it does not exist, jump to the login page

session_start();
if ( !$_SESSION['xxx'] ) {
    header("Location: login.php");
    exit;
}
Copy after login

Record the session after logging in

Destroy the session after logging out

[Recommended learning : "PHP Video Tutorial"]

The above is the detailed content of How to implement non-login jump in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template