Skip to content

Instantly share code, notes, and snippets.

@codebubb
Last active December 18, 2022 13:41
Show Gist options
  • Select an option

  • Save codebubb/ab5cfaf8b70d198e55a5642e9a63ab37 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

Can you explain this code?

@wavila88

wavila88 commented Dec 7, 2020

Copy link
Copy Markdown

@IanLu89

IanLu89 commented Aug 9, 2021

Copy link
Copy Markdown

Thx

@SuperLeo23

Copy link
Copy Markdown

How can I set a variable as a cookie?

@123luki

123luki commented May 17, 2022

Copy link
Copy Markdown

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