3

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.

6
  • have you cleared your cookies? Commented Dec 2, 2019 at 12:13
  • open both url in different browser ( one in chrome and other on firefox ), let us know your observation. Commented Dec 2, 2019 at 12:16
  • 1
    So 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 Commented Dec 2, 2019 at 12:24
  • I'm using different vhost for each version Commented Dec 2, 2019 at 12:41
  • Using same DB file for both versions Commented Dec 2, 2019 at 12:41

1 Answer 1

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',
        ];
Sign up to request clarification or add additional context in comments.

6 Comments

cache:clear is for flushing your cache store, it has nothing to do with the configuration or anything like that
php artisan config:cache also runs php artisan config:clear. And caching config on DEV systems is not advised
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()
@kerbholz finally someone else who gets that point about not needing it cached on development :) drives me crazy everytime someone says to cache it
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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.