title: User Permission System with CodeIgniter
body: <p>I'm re-developing my system using CodeIgniter, which i'm new, and i'm trying to load a function from my Controller that will check if the user has or not permission to see/access that feature.</p>
  
  <p>I'm using a <code>TEXT</code> in my DB with all the permissions that each user level has and then save the permissions into a session var do work with in my Controller.</p>
  
  <p>In my Controller <code>Users.php</code>:</p>
  
  <pre><code>public function UserHasPermissions($permission){
      checkSession($this);
  
      $arrayPermissions = explode($this-&gt;sessions-&gt;userdata('session_permissions'));
      if(in_array($permission, $arrayPermissions)){
          return true;
      } else {
      return false;
      }
  }
  </code></pre>
  
  <p>In my View <code>home.php</code> i'm doing the following try:</p>
  
  <pre><code>$this-&gt;load-&gt;view('commons/header');
  if($this-&gt;Users-&gt;UserHasPermissions('ADD_MEETING')){
      echo 'content';
  }
  $this-&gt;load-&gt;view('commons/footer');
  </code></pre>
  
  <p>And it's returning this error:</p>
  
  <pre><code>An uncaught Exception was encountered
  Type: Error
  
  Message: Call to a member function UserHasPermissions() on null
  
  Filename: /var/www/html/DF_CHECKER_CI/application/views/home.php
  
  Line Number: 4
  </code></pre>
  
  <p>I took a look at these docs but nothing really helped me much.</p>
  
  <p><a href="https://www.codeigniter.com/user_guide/general/views.html#adding-dynamic-data-to-the-view" rel="nofollow noreferrer">https://www.codeigniter.com/user_guide/general/views.html#adding-dynamic-data-to-the-view</a></p>
  
  <p><a href="https://stackoverflow.com/questions/9986520/how-to-call-codeigniter-controller-function-from-view">How to call codeigniter controller function from view</a></p>