I am trying to log out from a PHP website by using the following code:
<?php
session_start();
if(isset($_GET['logout']))
{
$_SESSION=array();
if($_COOKIE[session_name()])
{
setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();
header('Location: login.php');
}
?>
The page gets redirected to Login page but when I click back button of browser, I am able to see the previous page. Please suggest a comprehensive solution that can resolve this, since on various posts, I am not able to find a solution where User can completely logout the php website. (if possible, without using javascript). I want to be on the login page itself even when back button is pressed after logout.
session_start();
session_unset();
session_destroy();
header ('location:login.php?message=logout');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With