Laravel

Dealing with links after session expiry

Hello, I am stack when my sessions expire, all of my links seem active, then after clicking them, i see laravel header errors and null errors... i have created App/Exceptions/Handler.php, tried catching the errors from there, but the links still seem like they are active yet reflecting errors other than redirecting to the login page. Any help is greatly appreciated.

This is my code: for Handler.php

<?php namespace App\Exceptions; use Throwable; use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { /** * The list of the inputs that are never flashed to the session on validation exceptions. * * @var array<int, string> */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * Register the exception handling callbacks for the application. */ public function register(): void { $this->reportable(function (Throwable $e) { // }); } protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { return response()->json(['message' => 'Unauthenticated.'], 401); } if ($request->header('X-Inertia')) { return redirect()->route('auth.login')->with([ 'errors' => ['auth' => 'Session expired. Please log in again.'], ]); } return parent::unauthenticated($request, $exception); } } Please look through and see where you could correct me.
Speed Member
Speed
0
0
8