I am getting Csrf token mismatch error on every post request I am making in the project. I am using ajax at some places and normal form submission at other places. However the error is constant.
I have tried several things as suggested on this site like
- Setting
SESSION_SECURE_COOKIE=false. - Adding
@csrfinside<form></form> - Adding
<meta name="csrf-token" content="{{ csrf_token() }}" />and
$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content');}});before ajax call. - Running
php artisan config:clearphp artisan route:clearcomposer dump-autoload. - Running project on different browsers.
The error is same throughout. The application was working absolutely fine.
What is the thing I am missing?
>Solution :
In your config/session.php file, try setting same_site to lax,null.
After that run php artisan config:cache.