title: how to avoid user get into the login session even after logging out by clicking back?
body: <p>I have created a login form. It works fine, but it goes back to the logged in page if the user clicks back button after they log out.
  When I tried something to stop it, the index page stopped working. It shows problem loading page error.</p>
  
  <p>I have done this in my index page to avoid the user not to go back to logged in session but now the index page itself doesn't work.</p>
  
  <pre><code>if (!isset($_SESSION['user'])) {
      header('Location:index.php');
  }   
  </code></pre>
  
  <p>logout.php:</p>
  
  <pre><code>session_start();#This will start the session
  session_unset(); #Session_unset and Session_destroy
  session_destroy();#Will remove all sessions.
  
  header("location:index.php");#This code will sen du back to the index page
  </code></pre>
  
  <p>Once the user logs in the user logs in to this home page. I have added session like this:</p>
  
  <pre><code>session_start();
  
  $user = $_SESSION['user'];
  </code></pre>
  
  <p>Please correct me where I am wrong. The problems I am facing are:</p>
  
  <ol>
  <li>to make my index page display</li>
  <li>avoid user going back to their logged in session after logging out</li>
  </ol>