How to pass CSRF token with ajax request?

Posted by Andre Scott | Updated on

How to pass CSRF token with ajax request?

You can add the Csrf-Token header with the headers option. As stated in the Play Framework 2.6 Documentation, you may set a ‘ Csrf-Token ‘ Header with the token generated by Play:

If you are making requests with AJAX, you can place the CSRF token in the HTML page, and then add it to the request using the Csrf-Token header.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers