Session logout problem in php_PHP tutorial

WBOY
Release: 2016-07-13 10:36:49
Original
737 people have browsed it

In php, if you use session to determine whether the user is logged in or logged out, you can do this:

session_start();
session_destroy();

The session is now over. The next sentence should be written in js to make the page jump.

<script>alert("Logged out!");location.href="login.php";</script>

If it is a frame page, don’t use location directly. Because this will jump within a small frame page, the original intention must be to jump to the entire frame. Therefore, "parent." must be added before location.

The whole process is as follows (only for frame pages):

Copy the code The code is as follows:

< ?php
session_start();
session_destroy();
//To make the entire page of the frame jump to the login page
echo "<script>alert('Already logged out');parent .location.href='login.php';</script>";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/736847.htmlTechArticleIn php, if you use session to determine whether the user is logged in, when logging out, you can do this: session_start() ; session_destroy(); The session has ended. The next sentence should be...
Related labels:
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