Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dshaw002's avatar

TokenMismatchException and New Sessions every session for WHM Server

Hey, I've been trying to solve this problem for the past few days with no luck. Basically, I have a site that is fine in Laravel Homestead, but when the site was updated to Laravel 5.4 and put on a server, there's been issues with TokenMismatchException.

I've made sure the APP_URL and SESSION_DOMAIN was valid. The secure setting is set to false (regular HTTP server), I made sure everything was in the web route. I've also added CSRF tokens blocks to the header and javascript in the main layout template file.

Any ideas what else I can do? I checked other questions and pages about this issue to no luck.

Thanks.

0 likes
6 replies
bashy's avatar

Is the CSRF token changing on each refresh?

Have you got 'secure' => true but you're on HTTP?

dshaw002's avatar

The CSRF token is changing on each refresh.

secure is set to false and it's on HTTP.

bashy's avatar

There's loads of threads about this. It's always a small thing which I can't remember! Is your session storage writable?

dshaw002's avatar

I temporarily set the storage/framework/sessions folder to 777. The user and group settings check out as well.

I reviewed the other threads and tried out their ideas. I'm also going to check my WHM configuration. I normally don't use WHM/CPanel, but a client did.

dshaw002's avatar
dshaw002
OP
Best Answer
Level 1

Got it resolved. The issue was the site was set to APP_DEBUG=true and APP_STATUS=production. I think the debug mode was causing issues or the Laravel DebugBar/IDE-Helper with the site.

Thanks!

bashy's avatar

That shouldn't be messing with it but glad you got it sorted.

Please or to participate in this conversation.