title: PHP SESSION data lost between page loads with WAMPserver 2.0 on localhost
body: <p>I have a PHP authentication system on my website using the $_SESSION variable.</p>
  
  <p>A form submits a username and password to the file "login.php". It is handled like this:</p>
  
  <pre><code>&lt;?php include '../includes/sessionstart.inc.php'; ?&gt;
  &lt;?php ob_start(); ?&gt;
  
  if($_POST){
      $q = mysql_query("SELECT id, company FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."' AND password = '".md5($_POST['password'])."'");
      if(mysql_num_rows($q) &gt;= 1){
          $f = mysql_fetch_Array($q);
          $_SESSION['company'] = $f['company'];
          $_SESSION['id'] = $f['id'];
          $_SESSION['logedin'] = true;
          session_write_close();
  
          ob_clean();
          header("Location: index.php");
  
  }
  </code></pre>
  
  <p>Afterwards, index.php is loaded and checks whether 'logedin' is true.</p>
  
  <pre><code>&lt;?php include '../includes/sessionstart.inc.php'; ?&gt;
  &lt;?php if(!isset($_SESSION['logedin'])) header('Location: login.php'); ?&gt;
  </code></pre>
  
  <p>On my production server, it continues, but on my Wampserver, it reverts back to login.php. I notice that Wampserver is very slow in page loading, this might have to do something with it. That's why I included the session_write_close, to make sure session data is saved before the pages are switched, but it doesn't help.</p>
  
  <p>The contents of session_start.inc.php are simply:</p>
  
  <pre><code>&lt;?php
      session_start();
  ?&gt;
  </code></pre>
  
  <p>I used to have more code in there, but at the moment it's just this. The problem also existed before I started using an include file.</p>
  
  <p>Does anybody have an idea what I'm doing wrong? Why doesn't Wampserver transmit my SESSION data to the next PHP file?</p>