Support the ongoing development of Laravel.io →
Requests Session
Last updated 2 years ago.
0
Solution

Session expiration probably means that the user is logged out. In this case you can specify middleware on your routes that will redirect users if the route requires you to be logged in. That will redirect them to auth/ pages but user will not see any notification. You can of course edit your app/Http/Middleware/Authenticate file, @handle method and use

Session::put('message', 'You need to be logged in');

And on your auth/login page use

echo Session::get('message');
Last updated 9 years ago.
0

Hey, thank you for your answer. I added this at the beginning of the @handle method in the Authenticate middleware :

if (!Auth::check()) {
			
  Session::flash('message', trans('errors.session_label'));
  Session::flash('type', 'warning');

  return redirect()->route('home');

}

Don't know if there's a better way, but it works, thanks !

0

Sign in to participate in this thread!

Eventy

Your banner here too?

SynRJ synrj Joined 3 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.