Back to Error Center

419 Page Expired

Error Message

419 Page Expired

Cause

The CSRF token is missing or invalid. This happens when the form doesn't include @csrf, the session expired, or the token doesn't match.

Solution

Add @csrf to your Blade form. For AJAX, include the X-CSRF-TOKEN header. Check session configuration and lifetime. Verify the CSRF token meta tag exists.

Code Example

Fix
@csrf {{-- Add this to every form --}}

{{-- For AJAX requests --}}
<meta name="csrf-token" content="{{ csrf_token() }}">

<script>
fetch('/api/endpoint', {
    method: 'POST',
    headers: {
        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
        'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
});
</script>

Debugging Steps

  1. Add @csrf directive to the form
  2. Check the session cookie is present in the browser
  3. Verify CSRF token in the page source
  4. Check session expiration time in config/session.php
  5. Clear browser cookies and cache

Prevention

Always include @csrf in Blade forms. Set appropriate session lifetime. Use the meta tag for AJAX requests. Ensure session driver is properly configured.