03-19-2011, 04:31 AM
[eluser]Wondering Coder[/eluser]
I have this function in almost all of my controllers, this prohibit any unauthorized user to access a certain page in my site.
But what I would like to do is just call this function logged_in in just one controller and not doing a copy-paste thing. Is this the part where I would need to extend my controller? Haven't really tried it though. BTW - It's just been 3 months since I learned using CI.
I have this function in almost all of my controllers, this prohibit any unauthorized user to access a certain page in my site.
Code:
function is_logged_in()
{
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
echo 'You don\'t have permission to access this page. <a href="../login">Login</a>';
die();
//$this->load->view('login_form');
}
}
But what I would like to do is just call this function logged_in in just one controller and not doing a copy-paste thing. Is this the part where I would need to extend my controller? Haven't really tried it though. BTW - It's just been 3 months since I learned using CI.