title: php - session lost after refreshing page
body: <p>So I am developing a login system for my website and I would like to change the navigation bar when the user is logged but I can't get it to work because the session keeps getting lost after I refresh the page to update the navigation bar. This is what I got in my login.php script:</p>
  
  <pre><code>if ($loginNumRows == 1) {
     echo 'true';
     session_start();
     $_SESSION['username'] = $loginRow['name'];
  </code></pre>
  
  <p>When this echoes 'true', the following javascript is loaded:</p>
  
  <pre><code>if (html == 'true') {
      window.location.href = "index.php";
  </code></pre>
  
  <p>I tried with "location.reload(true);" and it is still the same. And in the main page, where the navigation bar is, I make the following check:</p>
  
  <pre><code>&lt;?php if (isset($_SESSION))
              {...}
  </code></pre>
  
  <p>However this always returns false. Any ideas what to do? Thanks!</p>