I'm trying to migrate laravel from version 5.2 to 6.0 , but i have different folder for different version in same local wamp server . I'm using same database file both version . But i'm always getting csrf token mismatch and page expired . Please give me some good solutions for this.
Asked
Active
Viewed 2,671 times
3
-
have you cleared your cookies? – lagbox Dec 02 '19 at 12:13
-
open both url in different browser ( one in chrome and other on firefox ), let us know your observation. – jagad89 Dec 02 '19 at 12:16
-
1So do you have different vhosts for the different versions or do you just use "localhost" for all those projects? I'd advice setting up vhosts with different domain names (i.e. "la52.local", "la56.local" etc.) for every project you have. Or use `php artisan serve` in the different folders – brombeer Dec 02 '19 at 12:24
-
I'm using different vhost for each version – Adil Basha Dec 02 '19 at 12:41
-
Using same DB file for both versions – Adil Basha Dec 02 '19 at 12:41
-
Which session driver are you using? – mdexp Dec 02 '19 at 13:18
1 Answers
1
This problem comes from the CSRF token verification which fails. So either you're not posting one or you're posting an incorrect one.
Use {{ csrf_field() }}
in your form
OR
Add Your Route URL into the Http/Middleware/VerifyCsrfToken.php
file.
Example Like this. If your ajax route Route::post('searchsubmit','User\UserController@ViewSearchList')->name('searchsubmit');
Http/Middleware/VerifyCsrfToken.php
protected $except = [
'searchsubmit',
];
In Your Case You need to add login
like this
protected $except = [
'login',
];

Vaibhavi S.
- 1,083
- 7
- 20
-
`cache:clear` is for flushing your cache store, it has nothing to do with the configuration or anything like that – lagbox Dec 02 '19 at 12:15
-
1`php artisan config:cache` also runs `php artisan config:clear`. And caching config on DEV systems is not advised – brombeer Dec 02 '19 at 12:15
-
this is a good solution but i dont recommend that. you should put csrf token for all your forms. maybe php clear all config and caches help you. you can also check @csrf instead of csrf_token() – ali Falahati Dec 02 '19 at 12:19
-
1@kerbholz finally someone else who gets that point about not needing it cached on development :) drives me crazy everytime someone says to cache it – lagbox Dec 02 '19 at 12:20
-
i used all above command , my problems is when another guys use same laravel project from my system in his system from networks this problems occur. – Adil Basha Dec 02 '19 at 12:21
-
@aliFalahati I'm using csrf_token in all forms , for repeatation of code i'm using csrf_token in master blade page . – Adil Basha Dec 02 '19 at 12:43