Back to Error Center

TokenMismatchException

Error Message

Symfony\Component\HttpKernel\Exception\TokenMismatchException

Cause

The CSRF token sent with the form doesn't match the token stored in the session. The session may have expired, or the token is stale.

Solution

Ensure @csrf is in every form. For SPAs, send the X-CSRF-TOKEN header. Clear browser cache and cookies. Check session configuration.

Code Example

Fix
@csrf {{-- Always include in Blade forms --}}

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

{{-- Axios automatically sends the token from meta tag --}}
axios.defaults.headers.common['X-CSRF-TOKEN'] = 
    document.querySelector('meta[name="csrf-token"]').content;

Debugging Steps

  1. Verify @csrf is in the form
  2. Check session cookie exists in browser
  3. Ensure session driver is configured
  4. Clear cookies and try again
  5. Check for multiple forms with different actions

Prevention

Use @csrf in every form. Configure session lifetime appropriately. For SPAs, ensure proper cookie handling.