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

GodziLaravel's avatar

CSRF token mismatch after login.

Hello, I have this error message : CSRF token mismatch

this Error is produced if I :

  • open two tabs A and B
  • when the session is expired on both tabs and I logged-in on the tab B
  • then I try to use Axios (post or get) on the tab A, it produces CSRF token mismatch

Any Idea please?

0 likes
3 replies
Sinnbeck's avatar

That is how the browser works. You will need to implement some way to refresh the token yourself. So for instance when the tab is opened, you send an ajax request to the backend to get a new csrf token. Or reload the page.

Please or to participate in this conversation.