Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Last active December 13, 2015 18:28
Show Gist options
  • Save bloodyowl/4955668 to your computer and use it in GitHub Desktop.
Save bloodyowl/4955668 to your computer and use it in GitHub Desktop.
getCookie
function getCookie(){
var cookie = document.cookie
, regExp = /\s*([\w\-]+?)\s*=\s*([^;]*?)\s*(?:;|$)\s*/g
, obj = {}
cookie.replace(regExp, function(match, name, value){obj[name] = value})
return obj
}
@bloodyowl
Copy link
Author

Returns an object representing the document.cookie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment