title: PHP unset and desroyed session starts itself
body: <p>I got a little problem with my php code here... Can you please help me out?
  The problem is that when i, in my logout.php, unsets and destroys sessions, it works the first time i load some of my other pages.. but when i refresh right after, the session is started again, which i dont really understand? Because i have my page to look for a session with a specific name. Here is my code:</p>
  
  <p><strong>Login.php:</strong></p>
  
  <pre><code>&lt;?php session_start();
  //Get username and password
  $email = $_POST['email'];
  $password = $_POST['password'];
  
  //Sorting special characters away, with exception of "-" and "."
  stripslashes($email);
  $email = preg_replace('/[^A-Za-z0-9@\.\-]/','', $email);
  
  
  //Getting the password from the database
  $link = mysqli_connect("****", "****", "****", "****");
  if (mysqli_connect_errno($connect)) 
  {
      echo "Connection Failed!";
      mysqli_close($connect);
  }
  $sql = "SELECT * FROM admins WHERE email = '". $email . "'";
  if ($result = mysqli_query($link, $sql))
  {
      while ($row = mysqli_fetch_row($result))
      {
          $db_password = $row[2];
      }
      mysqli_free_result($result);
  
  }
  mysqli_close($connect);
  
  //Compare DB-password to entered password
  if ($db_password == $password)
  {
      $_SESSION['admin'] = $email;
      header("Location: ../index.php");
      exit();
  }
  header("Location: index.php");
  exit();
  ?&gt;
  </code></pre>
  
  <p><strong>Logout.php:</strong></p>
  
  <pre><code>if(!isset($_SESSION['admin']))
  {
      header("Location: ../index.php");
      exit();
  }
  else
  {
      session_unset();
      session_destroy();
      echo '&lt;h1&gt;You have been succesfully logged out!&lt;/h&gt;';
      exit();
  }
  </code></pre>
  
  <p><strong>Index.php:</strong></p>
  
  <pre><code>if (isset($_SESSION['admin']))
  {
      echo '&lt;div id="admin"&gt;&lt;br&gt;
      &lt;h3&gt;'.$_SESSION["admin"].'&lt;/h3&gt;
      &lt;a href="http://www.mysite.com/admin"&gt;&lt;span&gt;Admin panel&lt;/span&gt;&lt;/a&gt;&lt;br&gt;
      &lt;a href="http://www.mysite.com/admin/logout.php"&gt;&lt;span&gt;Log out&lt;/span&gt;&lt;/a&gt;
      &lt;/div&gt;';
  }
  </code></pre>
  
  <p>And yes, i got <code>session_start()</code> on top of every one of my pages.</p>
  
  <p>As you can see in the index.php, i want some code to be written if <code>$_SESSION['admin']</code> is set. And when i destroy the session in my logout.php, and goes to index.php, it works the first time i load the page. But i i refresh, the code reappear, which means the session must have been set again, somehow! But i dont know why? Please help!</p>
  
  <p>EDIT: I have put the whole code of the login.php now. The rest of the other 2 pages, is pure HTML. What i have posted is all my PHP code!</p>