title: Codeigniter Login Logout button
body: <p>I am making first website using codeigniter framework.
  I have made a user class with a method to check if a user is logged in like :</p>
  
  <pre><code>public function is_logged_in()
  {
      $this-&gt;load-&gt;library('session');
      $loggedin = $this-&gt;session-&gt;userdata('logged_in');
      if ($loggedin)
      {
          return TRUE;
      }
      else
      {
          return FALSE;   
      }
  }
  </code></pre>
  
  <p>Now i have a menu in my header with a button which needs to change depending on the login status.
  If the user is not logged in i want to show a login button, else a logout button (with the right links of course).
  I think in MVC there should be only html and only php where needed.
  Where should i place the check to see if i show the login or logout button, should i do it in every controller where i call the header like:</p>
  
  <pre><code> $data['menubutton']= $this-&gt;getbutton();//something to get the button
   $this-&gt;load-&gt;view('templates/header', $data); 
  </code></pre>
  
  <p>If i would do it that way i need to add it to every controller, should i just do the check in the view, or is there another simple solution.</p>
  
  <p><strong>Question in short what is the best way/position to create the correct menu button depending on login status? (login or logout button)</strong></p>