Skip to content

Instantly share code, notes, and snippets.

@raxityo
Created September 4, 2022 14:13
Show Gist options
  • Save raxityo/84c2f0eeea68f64ef609b40e6f515166 to your computer and use it in GitHub Desktop.
Save raxityo/84c2f0eeea68f64ef609b40e6f515166 to your computer and use it in GitHub Desktop.
function prettyCookie() {
const cc = document.cookie.split(';').map(c => {
const [k, ...v] = c.split('=')
let vv = decodeURIComponent(v.join('='))
try {
vv = JSON.parse(vv)
} catch {}
return { [`${decodeURIComponent(k.trim())}`]: vv }
})
return Object.assign({}, ...cc)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment