0

Now I have a website , when I press log out button it return me to the login page, but if I change the url of the browser to menu.php for an example, I found the user is still on , I don't know how do I kill the session completely .

logout button will direct the user to logout.php which has the following code

<?php 
session_unset();
session_destroy();

header("Location: index.php");
exit();
?>

I was in menu.php and I click on Logout button. It direceted me to index.php as it's suppose to be. When I changed the url of the browser from index.php to menu.php I found the welcome message containing the last user name in!

menu.php suppose to not open if you click logout and did not sign in again

  • What have you tried to resolve the problem? Where are you stuck? How do you check for the current user in your menu.php? – Nico Haase May 29 '23 at 12:42
  • 2
    You must start the session before you can delete it if the session has not been initialized in logout.php. – Ferris May 29 '23 at 12:52

1 Answers1

0

I finally found it out. The guy who said that I must start the session before I end it was right

this is the new logout.php code

<?php 

session_start();

session_unset();
session_destroy();

header("Location: index.php");

?>
DarkBee
  • 16,592
  • 6
  • 46
  • 58