There is one csrf token per session. Once the session timeout is reached a new one is generated. There are a multitude of posts on this topic. Take your pick.
Nov 21, 2015
5
Level 2
multiple valid CSFR tokens for multiple forms\post per page?
I have a page that dynamically loads multiple forms via ajax. Because of this, SOME forms have different csrf tokens, and from what I can see only the latest token is stored in the session, therefore I'm getting TokenMismatchException errors when submitting any previously created form.
(think of this page sort having multiple yes\no questions, as soon as you answer one question, it slides off the screen and another question is loaded, therefore multiple forms\ajax request and tokens)
- Should I load the main page with a csrf token and share it with all the dynamically created forms? (when will the original token expire)
- Is there a way to let laravel accept more than one token?
- Why would some forms share the same token, and others created later have different tokens?
- Short of disabling csrf for this URI, any other work-arounds?
Please or to participate in this conversation.