Roles Management Library for Codeigniter Framework
first of all , roles must be in config/roles.php
as array like the following example
config/roles.php
----------------
$config['all_roles'] = array(
// use public for visitors and non-logged in users
'public' => array(
'default_page' => 'home',
'allowed_pages' => ['home/*','welcome/index','welcome/login'],
'blocked_pages' => ['welcome/*']
),
'admin' => array(
'default_page' => 'welcome/defaultPage',
'allowed_pages'=> ['welcome/*'],
'blocked_pages'=> ['']
),
// another example
'user' => array(
'default_page' => 'user/defaultPage',
'allowed_pages' => ['user/*'],
'blocked_pages'=> ['user/backup'],
),
);
$this->load->library('authct');
$this->authct->setUserRole('admin'); // set role name in session
$this->authct->checkCurrentUri(); // check the current uri
$this->authct->is_role('admin'); // return 1 if user role is equal to admin
for more, take a look at controllers/Welcome.php
& controllers/Home.php