Skip to content

Instantly share code, notes, and snippets.

@philippeowagner
Forked from mbrochh/gist:3338679
Created October 7, 2013 11:25
Show Gist options
  • Select an option

  • Save philippeowagner/6866316 to your computer and use it in GitHub Desktop.

Select an option

Save philippeowagner/6866316 to your computer and use it in GitHub Desktop.
function getCSRFToken() {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, 10) == ('csrftoken' + '=')) {
cookieValue = decodeURIComponent(cookie.substring(10));
break;
}
}
}
return cookieValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment