In my default controller session's value is set.
now in my every controller that calls different view, I wants to check if session's value is set then only that view will be shown otherwise it will redirect user to the log in view.
So, as per my knowledge I have to check session's value in my every controller is there any shortcut way?? or is there any way to call one file/function which is called every time before call of any controller. so I can check session's value there.
I had try via hook also like this :
class Authentication extends CI_Hooks {
var $CI;
function __construct() {
$this->CI = & get_instance();
}
public function verify_session() {
if (!isset($this->CI->session)) {
$this->CI->load->library('session');
$user_session_id = $CI->session->userdata('email');
if ($user_session_id == '') {
redirect('common_controller/home_controller');
}
}
}
}
but it shows me eroor like this : Severity: Notice
Message: Trying to get property of non-object
Filename: hooks/Authentication.php
Line Number: 20