[eluser]Unknown[/eluser]
I just want to write a helper function that checks if you are logged in, and if not it will redirect you to the login page. It seems that I cannot access $this->session through a helper function though.
Basic function:
Code:
function check_logged_in()
{
$logged_in = $this->session->userdata('logged_in');
//$client_id = $this->session->userdata('client_id');
if (!$logged_in)
{
redirect('/login');
}
}
If I try to call that function via the helper then I get a server error 500. However, if I put that same code into the a controller function then it works just fine.
Would I need to use a hook in this case?