Skip to content

Instantly share code, notes, and snippets.

@codebubb
Last active December 18, 2022 13:41
Show Gist options
  • Save codebubb/ab5cfaf8b70d198e55a5642e9a63ab37 to your computer and use it in GitHub Desktop.
Save codebubb/ab5cfaf8b70d198e55a5642e9a63ab37 to your computer and use it in GitHub Desktop.
Decode Cookie string to a single object
document.cookie
.split(';')
.map(cookie => cookie.split('='))
.reduce((accumulator, [key, value]) => ({ ...accumulator, [key.trim()]: decodeURIComponent(value) }), {});
@SriBalajiE
Copy link

Can you explain this code?

@wavila88
Copy link

wavila88 commented Dec 7, 2020

@IanLu89
Copy link

IanLu89 commented Aug 9, 2021

Thx

@SuperLeo23
Copy link

How can I set a variable as a cookie?

@123luki
Copy link

123luki commented May 17, 2022

image
Hallo Kannst du mir vielleicht sagen was da gemacht wurde?

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