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

awdelyea's avatar

Many subsequent ajax requests leads to weird session issues

So I have a little javascript applet that does sequential uploads to a server.

Right now, if I queue 20 uploads, usually around 17-18 will succeed. The three that fail do so because of TokenMismatch exceptions. Digging in the code finds that the supplied csrf token doesn't match the one pulled from the session.

When I send each ajax request, I'm sending a common csrf_token generated on page load. The files that fail aren't at the end or at the beginning: they're at random. Later files pass the csrf check.

As a hail mary, I tried removed csrf protection from the route. This leads to a completely different error where my entire session is deleted between two uploads, none of the other uploads success, and I'm logged out of the app completely.

PHP: 5.5.12 Apache: 2.4.9 Platform: Windows Laravel 5.1.28 Using Redis for the session driver

0 likes
0 replies

Please or to participate in this conversation.