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

JacDev's avatar

[Solved] Tokenmismatchexception on every 2nd page

Hello,

Do the tokens from the laravel application change often? I have an application and if I go to any page, it just works (it uses javascript to retrieve information and gives with that a token parameter). So on every page it just works. Now if I go from one page (order page) to the next page (payment page), I get an tokenexception everytime when I do the javascript call. If I am checking with firebug the token from the 1st page is identical to the one on the 2nd page, so I'd expect it to be alright. But somehow I keep getting the error 500 tokenmismatch on line 68.

If I open the payment page directly, it just works perfectly. Is there anyway how I can debug when and where the tokens are being changed or so? I actually do see a 2nd session being created in the storage/framework/sessions directory. But I have no clue hay this happens. Any suggestions are welcome.

My session.php config:

Driver = File, Encrypt = False, Lifetime = 120, Secure = False, http_only = True

0 likes
3 replies
JacDev's avatar

It is passed to the final page. But only when the final page opens. Then a javascript parameter is saved that is being used for the javascript calls. But it seems that somehow between the pageload and the javascript calls the token is being changed. But I have no idea why it changes. So do I have to change the javascript token value after each javascript call? Since I have no idea why the token gets changed inbetween and it gives me errors. Shouldn't tokens (/sessions) not just be longer active?

JacDev's avatar
JacDev
OP
Best Answer
Level 1

I stopped using the build in webserver on my development environment and started using Xampp as a webserver and load the project in that environment. For now that seems to have solved the problem. Otherwise I'll get back here. Thanks for takiung the time to answer jirdw

Please or to participate in this conversation.