Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucaswxp/7fc55dc64f25b2f7e417 to your computer and use it in GitHub Desktop.
Save lucaswxp/7fc55dc64f25b2f7e417 to your computer and use it in GitHub Desktop.
read all cookies as object/array javascript
function readCookies() {
var cookies = document.cookie.split(';'),
r = {};
for(var i=0;i < cookies.length; i++) {
var c = cookies[i],
sep = c.indexOf('=');
r[c.substr(1, sep-1)] = c.substr(sep+1);
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment