Laravel 5.4 Token Mismatch Exception on live server

1.8k Views Asked by At

I am facing Token mismatch exception in Laravel 5.4 on live server. On my local machine running Windows XAMPP, the application works fine. When I deployed it to live machine running CENTOS 7 and LAMP stack, I see a redirecting to myhostname.com/login at the top left corner of the browser and then lands on an error page showing:

token mismatch exception on line 68 of VerifyCsrfToken.php.

2

There are 2 best solutions below

4
On BEST ANSWER

I had this same problem and what i did was:

First in your .env file remove: SESSION_DOMAIN And in set session driver like: SESSION_DRIVER=file (if your want it to save to a file)

then do: php artisan cache:clear then `php artisan config:clear

that worked for me.

0
On

Try to clear config cache on the server with :

artisan cache:config

You will need to clear config cache also if you edited config/app.php for some reason.

In addition there is an other possible reason : you copied not only the application but also the cache/session files when you deployed your application to production. Basically everything in the storage folder should be ignored on deployment.