title: PHP Sessions - User not stored after login
body: <p>I am building a basic password protected area on my website and I have a login form.</p>
  
  <pre><code>&lt;!-- login.php --&gt;
  &lt;?php
  session_start();
  ?&gt;
  &lt;?php if(!empty($_SESSION['user'])) { ?&gt;
  &lt;form&gt;
      &lt;input type="text" name="username" /&gt;
      &lt;input type = "password" name = "password" /&gt;
      &lt;input type="submit" value = "login" /&gt;
      &lt;input type="hidden" name="token" value="KdasS2wFgw24F7hh" /&gt;
  &lt;/form&gt;
  &lt;?php } else { ?&gt;
  You are already logged in.
  &lt;? } ?&gt;
  
  
  &lt;!-- dologin.php --&gt;
  
  &lt;?php
  $allowed = //sql checking db
  if($allowed &gt; 0) {
      $_SESSION['user'] = $row['user_id'];
  }
  header("Location: login.php");
  ?&gt;
  </code></pre>