Is it a good practice to recreate the CSRF Token once its been used (basically create a new taken after a post request is sent)? Or it an unnecessary measure to take? My current system is recreating the token after each post/delete/put request and currently its causing me some serious trouble with a part of my code where I need to make multiple POST requests one after another, and since the system restarts the token as it starts the POST request, the other requests get "Invalid Token" error.


1 Answer 1


I think you should only create/change the token on every user login. If you change the token mid-session, it will invalidate all the links the user could have opened on new windows. And you will have lots of confused users.

If you think about it, there's no addition to security by changing the token. If any attacker cannot guess the first tag, s/he will not be able to guess the new one. If the first token is guessable, any other token will be too.

  • This approach also minimizes complexity of the implementation. Keeping the implementation simple reduces the likelihood of implementation flaws that can result in additional vulnerabilities.
    – atk
    Sep 5, 2014 at 1:08

Not the answer you're looking for? Browse other questions tagged .