Skip to content

Instantly share code, notes, and snippets.

@kynatro
Created Sep 29, 2014
Embed
What would you like to do?
Cookies as an Object (Major modern browsers and IE9+)
document.cookie.split("; ").map(function(i){
return i.split("=");
}).reduce(function(o, v, i){
try {
o[v[0]] = JSON.parse(decodeURIComponent(v[1]));
} catch(e) {
o[v[0]] = decodeURIComponent(v[1]);
}
return o;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment