Created
September 12, 2017 00:56
-
-
Save parrotmac/f54eb5fe6026d33ba712b239872461ff to your computer and use it in GitHub Desktop.
One-liner to get Django's CSRF token cookie from Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.cookie.split(";").map(cookie => {var _csrf = cookie.indexOf("csrftoken")===0?cookie.split("=")[1]:0; if(_csrf)return _csrf })[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment