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
- Add @csrf directive to the form
- Check the session cookie is present in the browser
- Verify CSRF token in the page source
- Check session expiration time in config/session.php
- 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.