laravel login page expired code example

Example 1: laravel form submit page expired

{{ csrf_field() }}

Example 2: laravel page expired redirect to login

# add function in  app/Exceptions/Handler.php


protected function prepareException(Exception $e)
{
        if ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        } elseif ($e instanceof AuthorizationException) {
            $e = new AccessDeniedHttpException($e->getMessage(), $e);
        } elseif ($e instanceof TokenMismatchException) {
              return redirect()->route('login');
        }
        return $e;
}

Tags:

Php Example