Skip to content

Instantly share code, notes, and snippets.

@pstjean
Created October 8, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pstjean/07eb59eba2e9aa870f0abedeb0441b76 to your computer and use it in GitHub Desktop.
Save pstjean/07eb59eba2e9aa870f0abedeb0441b76 to your computer and use it in GitHub Desktop.
Create an object containing all cookies in a document
Object.fromEntries(
document.cookie
.split(";")
.map(cookie => cookie.match(/([^=\s]+)=(.*)/).slice(1, 3)),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment