<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// Name of Class as mentioned in $hook['post_controller]
class Login_chk extends CI_Hooks{
 
    function __construct() {
       // Anything except exit() :P
    }
 
    // Name of function same as mentioned in Hooks Config
    function loginCheck() {
    	$CI = & get_instance();
    	$class = $CI->router->fetch_class();
			$sess = ($CI->session->userdata('logged_in')) ? $CI->session->userdata('logged_in') : array();
    	if(!element('role', $sess) && $class != 'login' && $class != 'forgetPassword'){
    		redirect(base_url().'login', 'refresh');
    	}
    }
 
}