lundi 7 mars 2016

Checking if a user is logged in/ logged out using Laravel 5

I wish to be able to determine if a user is logged in or not.

The way I am doing this is by having a is_logged_in field in the users table.

However I am unsure in how to update this variable, as I don't know what method is called during logout.

I assume it would be something like this:

class AuthController extends Controller
{
    //...
    public function login($user)
    {
        $user->is_logged_in = true;
        $user->save();
    }

    public function logout($user)
    {
        $user->is_logged_in = false;
        $user->save();
    }

    //...
}

Thanks for the help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire