Skip to content

Instantly share code, notes, and snippets.

@ydm
Last active December 15, 2015 14:59
Show Gist options
  • Save ydm/5278917 to your computer and use it in GitHub Desktop.
Save ydm/5278917 to your computer and use it in GitHub Desktop.
getCookie = (name) ->
if document.cookie and document.cookie.length > 0
cookies = ($.trim(i) for i in document.cookie.split(';'))
for cookie in cookies
if cookie.substring(0, name.length + 1) == "#{name}="
val = decodeURIComponent cookie.substring(name.length + 1)
return val
return null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment