title: Session works when clicking on link, but not when typing the linkadress in URL or clicking on the "Go Back" button in browser
body: <p>I have a problem with my sessions. It seems that when the user log out the thing works. The user can't access the memberarea. But the thing is if someone would write the adress in the URL-bar for the memberarea page, they will be able to access it and also click on some only-for-members-pages.</p>
  
  <p>This is how my code looks like for login.php</p>
  
  <pre><code>&lt;?php
  session_start();
  
  if(isset($_SESSION['usr_id'])!="") {
      header("Location: profileuser");
  }
  
  include_once 'Db.php';
  
  //check if form is submitted
  if (isset($_POST['login'])) {
  
      $email = mysqli_real_escape_string($con, $_POST['email']);
      $password = htmlentities(mysqli_real_escape_string($con, $_POST['password']));
      $result = mysqli_query($con, "SELECT * FROM table WHERE email = '" .  $email. "' and password = '" . md5($password) . "'");
  
      if ($row = mysqli_fetch_array($result)) {
          $_SESSION['usr_id'] = $row['id'];
          $_SESSION['usr_name'] = $row['email'];
          $_SESSION['usr_fname'] = $row['name'];
           $_SESSION['usr_ename'] = $row['ename'];
             $_SESSION['usr_vip'] = $row['vipoo'];
          header("Location: profile");
      } else {
          $errormsg = "&lt;script&gt;alert('Wrong!')&lt;/script&gt;";
      }
  }
  ?&gt;
  </code></pre>
  
  <p>This is how it looks for every membership page at the very top.</p>
  
  <pre><code>&lt;?php
  session_start();
  if(!isset($_SESSION["usr_id"])){
  header("Location: index");
  exit(); }
  include_once 'Db.php';
  ?&gt;
  </code></pre>