Skip to content

Instantly share code, notes, and snippets.

@contra contra/
Created Apr 24, 2012

What would you like to do?
Tiny cookie getter/setter javascript/coffee-script
cookie = (name, value) ->
if name and value
document.cookie = "#{name}=#{value};"
return value
out = {}
for cookie in document.cookie.split ";"
pair = cookie.split "="
out[pair[0]] = pair[1]
return (if name? then out[name] else out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.