title: CodeIgniter, PHP and reloading the front page when session is destroyed
body: <p>I am trying to create a web page where users should be able to register, log in and log out. This all works fine, however, a user is required to press the Sign Out button twice for the page to reload, or at least that's how I see it...</p>
  
  <p>here's some code:</p>
  
  <p>this is the top my page, with the log in / log out options</p>
  
  <pre><code>&lt;div id="topmenu"&gt;
          &lt;?php
  
          if(!isset($_SESSION['check'])) {
          echo ' Welcome, &lt;a href="/index.php/login/"&gt;Log In&lt;/a&gt; &lt;a href="/index.php/register/"&gt;Register&lt;/a&gt; ';
          }
          else {
          echo ' Welcome, ' .$_SESSION['name'] .'! &lt;a href="/index.php/login/destroy/"&gt;Sign Out&lt;/a&gt;'; 
          }
  
          ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's what the destroy function does in the login controller</p>
  
  <pre><code>public function destroy()
      {
          session_destroy();
          $this-&gt;load-&gt;view('frontpage');
      }
  </code></pre>
  
  <p>when the Sign Out button is pressed, the frontpage view is loaded, however this bar at the top (the topmenu div) stays the same, and still shows the sign out option, even though the session has been destroyed </p>