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
- Verify @csrf is in the form
- Check session cookie exists in browser
- Ensure session driver is configured
- Clear cookies and try again
- Check for multiple forms with different actions
Prevention
Use @csrf in every form. Configure session lifetime appropriately. For SPAs, ensure proper cookie handling.