title: PHP Session Variable disappears after page refresh
body: <p>I have a big problem and i cant solve it. My session variables are exchanged between files but after refresh of the second page they disappear.</p>
  
  <p>Here's the code:</p>
  
  <p><strong>index.php</strong>
      
  
  <pre><code>session_start();
  
  header('Title: So random');
  header('charset: UTF-8');
  
  //if index.php?login is requested
  if(isset($_REQUEST['login'])) {
  
      //'pass' input box value (from POST) is saved to $pass variable.
      $pass = $_POST['password'];
  
      //if pasword matches Password.
      if($pass == 'Password') {
  
          //session_start();
  
          $_SESSION['logintoken'] = "approoved";
          header("Location: list.php");
          die();
  
      } else { $error = true; }
  
  }
  
  if(isset($_SESSION['logintoken'])) { 
          header('Location: list.php'); 
          die();
      }
  
  
  ?&gt;
  Random HTML With login page goes here...
  </code></pre>
  
  <p>And then we have page, which is availble only for logged in. After redirecting from login to it it's okay but after refresh i have "logintoken not defined".</p>
  
  <p><strong>list.php</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  
  if($_SESSION['logintoken'] != "approoved") { 
      //'&lt;meta http-equiv="REFRESH" content="0; url=index.php"&gt;'
      die();
  }
  
  ?&gt;
  &lt;html&gt; goes here....
  </code></pre>