Skip to content

Instantly share code, notes, and snippets.

@parrotmac
Created September 12, 2017 00:56
Show Gist options
  • Save parrotmac/f54eb5fe6026d33ba712b239872461ff to your computer and use it in GitHub Desktop.
Save parrotmac/f54eb5fe6026d33ba712b239872461ff to your computer and use it in GitHub Desktop.
One-liner to get Django's CSRF token cookie from Javascript
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