"prevent back button after logout" Answer’s


Implement this in PHP and not javascript.

At the top of each page, check to see if the user is logged in. If not, they should be redirected to a login page:

      if(!isset($_SESSION['logged_in'])) : 
      header("Location: login.php");  

As you mentioned, on logout, simply unset the logged_in session variable, and destroy the session:


If the user clicks back now, no logged_in session variable will be available, and the page will not load.

Wednesday, March 31, 2021
answered 11 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :