session logout problem in php
- 2021-01-06 00:29:41
- OfStack
In php, if you use session to determine whether the user is logged in or not, you can log out like this:
session_start();
session_destroy();
The session is over. The next sentence should have been js, causing the page to jump.
< script > alert(" Log out!" ); location.href="login.php"; < /script >
If it's a frame page, don't use ES26en directly. Because this can jump inside 1 small frame page, original intention 1 is to want whole frame to jump in the past. So "parent." should be added before location.
The process is as follows (for frame pages only) :
<?php
session_start();
session_destroy();
// To make the entire page of the framework jump to the landing page
echo "<script>alert(' Have logged out ');parent.location.href='login.php';</script>";
?>