Skip to content

Instantly share code, notes, and snippets.

@ceme
Forked from rendro/parsecookie.js
Created August 29, 2020 02:54
Show Gist options
  • Save ceme/f847260c1f721921f42caf21442b09ca to your computer and use it in GitHub Desktop.
Save ceme/f847260c1f721921f42caf21442b09ca to your computer and use it in GitHub Desktop.
Parse document.cookie into object
document.cookie.split(';').map(function(c) {
return c.trim().split('=').map(decodeURIComponent);
}).reduce(function(a, b) {
try {
a[b[0]] = JSON.parse(b[1]);
} catch (e) {
a[b[0]] = b[1];
}
return a;
}, {});
@ceme
Copy link
Author

ceme commented Aug 29, 2020

javascript:(function(){var cookieJar = document.cookie.split(';').map(function(c) { return c.trim().split('=').map(decodeURIComponent); }).reduce(function(a, b) { try { a[b[0]] = JSON.parse(b[1]); } catch (e) { a[b[0]] = b[1]; } return a; }, {}); ;console.log(cookieJar)})();

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