Security
Laravel 8
Laravel 9
Laravel 10
Laravel 11
Laravel 12
419 Page Expired Error in Laravel - CSRF Token Fix
The 419 Page Expired error occurs when Laravel's CSRF token is missing, expired, or invalid during form submission.
The Error
Error Message
419 Page Expired
Common Causes
- 1 Missing @csrf directive in form
- 2 Session expired while form was open
- 3 CSRF token not included in AJAX request headers
- 4 Mismatched session domain configuration
- 5 Cookie/session configuration issues
Solutions
1
Add @csrf directive to your form
Blade
<form method="POST" action="/submit">
@csrf
<!-- form fields -->
</form>
2
Add CSRF token to AJAX requests
JavaScript
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
3
Add meta tag for CSRF token
Blade
<meta name="csrf-token" content="{{ csrf_token() }}">
4
Exclude route from CSRF verification (use cautiously)
PHP
// In VerifyCsrfToken.php
protected $except = [
'/webhook/*',
];
Need Help With Your Laravel Project?
I specialize in building custom Laravel applications, process automation, and SaaS development. Whether you need to eliminate repetitive tasks or build something from scratch, let's discuss your project.
About Hafiz
Senior Full Stack Developer. I build production software with Laravel, Filament, Vue, and AI integrations, and write about the real decisions behind shipping it.
Get in touch →