Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

juan's avatar
Level 1

Laravel session gets lost

This is regarding the session files that are created and updated on Storage > framework > sessions Folder. When I log in to my application and leave it there for a while, it logs me out and take me back to my log in box. However, I notice a second session, on the folder I mentioned, is created...keeping the previous one with some information. Do you guys have any idea why it is doing that?

By the way, O changed values on Config > session.php ( lifetime to 1000 and expire_to_close to true)

0 likes
6 replies
consigliere's avatar

do you have the routes under the web middleware? are you sharing sessions in subdomains? (check your config > session)

tykus's avatar

Session Garbage Collection is a lottery - the old session will be cleaned out (eventually)

juan's avatar
Level 1

Thanks for the reply... @consigliere , yes I do have most of my routes under middleware; e.i Route::get('dashboard', ['middleware' => 'auth', 'uses' => 'DashboardController@view']);

@tykus_ikus , I did not know about the garbage collector on laravel; so I guess I have to wait uh

consigliere's avatar

I mean is it under the web middleware like this? assuming you are running Laravel 5.2

Route::group(['middleware' => ['web']], function () {
    Route::get('dashboard', ['middleware' => 'auth', 'uses' => 'DashboardController@view']);
});
juan's avatar
Level 1

Thanks for the reply Consigliere. I am using Laravel 5.1. The way I have my routes are like this

Route::get('dashboard', ['middleware' => 'auth', 'uses' => 'DashboardController@view']);

without the web middleware

freel's avatar
in the controller where my user should be loged in 
public function __construct()
    {
        $this->middleware('auth');
    }

Please or to participate in this conversation.