Skip to content

Instantly share code, notes, and snippets.

@haileys
Forked from jacobh/gist:2785812
Created May 25, 2012 05:03
Show Gist options
  • Save haileys/2785862 to your computer and use it in GitHub Desktop.
Save haileys/2785862 to your computer and use it in GitHub Desktop.
Django ajax csrf coffeescript
document = cookie: "hello=world;this=that;what=which"
getCookie = (name) ->
if document.cookie
for [_, k, v] in (/^(.*?)=(.*)$/.exec kv for kv in document.cookie.split ";")
if k is name
return decodeURIComponent v
console.log getCookie "this"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment