Search code examples
laravellaravel-jetstreamlaravel-authentication

laravel 8 jetstream logout


I m using Laravel 8 - Jetstream for Authentification and i set a session variable : session(['isAdmin'=>'true']) on login :

//app\Providers\JetstreamServiceProvider.php

...

public function boot()
{
  ...
    
  Fortify::authenticateUsing(function(LoginRequest $request){
  ...
  //verifications
  session(['isAdmin'=>'true'])
  ...

}

If The user Logs out in Jetstream (using POST request to /logout) the session('isAdmin') is null.
The problem is what if the user didn't Log out but the session expired , because then the session('isAdmin') will be null but the user is still logged in (he didn't use the POST request to /logout ) .
I can't test this because i don't know if the session variables expire or no in Laravel maybe it's using database for sessions …
Any informations on how does the Laravel session works with the Authentification system in Jetstream ?


Solution

  • on /logout the user gets logged out from the Application and user session reset and hence all session data destroy. like in your case session('isAdmin') is set to null.

    In case of session expire and user is not logged out using post request to /logout, then the session will also reset on next request(post session expire). In this case user will be logged out(as session expired) and session data will be destroyed. This works in same way for file and database driver for session.