I'm redesigning a system in CodeIgniter, I'm new to it, and I'm trying to load a function from my Controller that will check whether or not the user has access to such a resource / screen / etc.
I'm using a TEXT
field in the database with all the permissions for each user level that I then bring them inside a session variable with the login procedure and I try to check the permission.
On my Controller Users.php
:
public function UserHasPermissions($permission){
checkSession($this);
$arrayPermissions = explode($this->sessions->userdata('session_permissions'));
if(in_array($permission, $arrayPermissions)){
return true;
} else {
return false;
}
}
In my View% with% I'm doing the following test.
$this->load->view('commons/header');
if($this->Users->UserHasPermissions('ADD_MEETING')){
echo 'content';
}
$this->load->view('commons/footer');
And I'm getting the following error:
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
I have read some articles but could not translate them to my need.