title: Session Codeigniter - Automatic Check data
body: <p>What would be the best way to work with sessions CodeIgniter to do the following ?</p>
  
  <p>I have users with a role and a company that are stored in a database.</p>
  
  <p>I want identify user role and company without do :</p>
  
  <pre><code>if($roles == 'Editor'): 
  
  // do something
  
  endif;
  </code></pre>
  
  <p>In each controller or method. </p>
  
  <p><strong>Example :</strong></p>
  
  <p>If users is logged a function in header checks that and if not it redirects to the homepage.</p>