When a user session is expired and the app is still open in browser, the app redirects to the login page when the user clicks a link in the app while not being authenticated any longer. So far so good. But I also have pages with FullCalendar, where certain JavaScript(!) functions are triggered by mouse click. Here, the function throws a 419 error (page has expired) and does not redirect to the login page but leaves the user with an error message.
What is the best way to handle this? I think it would be good to have the app automatically redirect to the login page once the session expires, so any 419 error could be avoided. Is this possible? If so, how to do this, does it need a job or event to make the app redirect itself once the session expires?
From my session.php:
'lifetime' => env('SESSION_LIFETIME', 60),
From my LoginController.php:
public function Logout(){
auth()->logout();
return redirect(’/login’);
}