I've done that but the problem is after It redirects me to the login page and after I login, it redirects me to the home page but i want it to redirect me to the previous page i was on
or check out the correct usage of that. Or you might need to store the path somewhere or cache it, and use that one. Because it will use the Login redirect path otherwise.
@thedesignlog when I think more about this, instead of redirecting to the login page in the Exception handler, redirect back which whould logout the user and then when you login it should show you the previous page instead. Try and let me know :)
I figured it out. i used this which will attempt to load my current page which i have set the auth middleware in it's controller so it redirects me to login page since the session has expired and then takes me back to my previous after I login.
Might seem complicated but it works
if ($request->is('cart/*')) {
if ($exception instanceof \Illuminate\Session\TokenMismatchException) {
return redirect()->route('cart');
}
} else {
if ($exception instanceof \Illuminate\Session\TokenMismatchException) {
return redirect()->route('login');
}
}