Welcome Guest, Not a member yet? Register   Sign In
community auth is_logged_in
#1

[eluser]chrisco23[/eluser]
How are people making use of the is_logged_in() function in Community Auth?

First I tried handling it in MY_Controller.php, redirecting the user to the user controller if not logged in but of course that doesn't work because the user controller extends MY_Controller.php. Hence, endless redirection.

Then I tried putting the following in the index() method of one of my controllers (though I'd rather not have to repeat this code on all my controllers which will all require the user to be logged in):
Code:
if (!$this->is_logged_in()) {
    redirect('user');
}

...and for whatever reason, even if I'm logged in, I never get past the user controller, ie. always redirecting there.

This all came about because the initial problem I found was that when I returned to work on the site after some time (after the session expired), my controller was looking for $this->auth_user_id, failing, and spitting out an ugly PHP Notice.

There must be a simple and elegant solution that somehow eludes me this morning.


Thanks,
Chris




Theme © iAndrew 2016 - Forum software by © MyBB