title: CodeIgniter setting userdata session
body: <p>Hi guys having a bit of a problem with setting userdata to true, maybe someone on here can help me out?</p>
  
  <p>I am using codeigniter </p>
  
  <p>here is my controller where I set the userdata and redirect forward to another controller "site" and call the function members_area</p>
  
  <pre><code>    if($query) // if the users pass/user is right
      {
          $data = array(
          'username' =&gt; $this-&gt;input-&gt;post('username'),
          'is_logged_in' =&gt; true      
          );
          $this-&gt;session-&gt;set_userdata($data);
          redirect('site/members_area');
      }
      else{
      $this-&gt;index(); 
  
      }
  </code></pre>
  
  <p>Then this is my site controller:</p>
  
  <pre><code>function __construct(){
  
      parent::__construct();
      $this-&gt;is_logged_in();
  }
  
  function members_area()
  {
  
      $this-&gt;load-&gt;view('members_area');
  }
  
  function is_logged_in()
  {
      $is_logged_in = $this-&gt;session-&gt;userdata('is_logged_in');
  
      if(!isset($is_logged_in) ||  $is_logged_in != true)
      {
          echo 'You don\'t have permission to access this page. &lt;a href="../login"&gt;Login&lt;/a&gt;';
          die();
  
      }
  
  }
  </code></pre>
  
  <p>What do you guys reckon? Much appreciated!</p>