Yesterday, i was working on new laravel 5.5 blog and i was making quick contact us form and i didn't use Form facade for that. i just simply use html input form element. But when i create post route and then submit my form i got following error:
The page has expired due to inactivity.
Please refresh and try again.
I was thing i haven't seen this error on my laravel 5.4 or 5 application. Then i search on google and found it is a "TokenMismatchException" error that was on laravel 5 old version. We can prevent this error using csrf_field() field. Laravel gives security on token based so you must have to pass csrf_field token on post submit method So, let's use following token by as bellow:
Add csrf token hidden field on Form:
{!! csrf_field() !!}
OR
<input type="hidden" name="_token" value="{{ csrf_token() }}">
You can add above way to csrf_token in your form. So don't get again same error.
I hope you found your best solution...
Do you like below Tutorials ?
- Angular Json Pipe Example | Json Pipe in Angular 9/8/7
- Angular Slice Pipe Example | Slice Pipe in Angular 9/8/7
- Angular Uppercase Pipe Example | Uppercase Pipe in Angular 9/8/7
- Angular LowerCase Pipe Example | LowerCase Pipe in Angular 9/8/7
- Angular Titlecase Pipe Example | Titlecase Pipe in Angular 9/8/7
- Angular KeyValue Pipe Example | KeyValue Pipe in Angular 9/8/7
- Call Method from One Component to Another Component in Angular
- Angular Push Object into Array Example