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

How to implement non-login jump in php

藏色散人
藏色散人Original
2021-03-11 09:06:432447browse

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;
}

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!

Statement:
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