Closed dmuneras closed 4 years ago
The cookie value string can use encodeURIComponent() to ensure that the string does not contain any commas, semicolons, or whitespace (which are disallowed in cookie values).
encodeURIComponent/decodeURIComponent escape sequences (e.g. comma, quotes, [], : , ; etc)
example:
// set
encodeURIComponent('my-app:cool-cookie') // "my-app%3Acool-cookie"
// get
decodeURIComponent("my-app%3Acool-cookie") // "my-app:cool-cookie"
Hi!
I would love to know why do you use
encodeURIComponent
when setting the cookie. it could be problematic if you have cookie keys that includes: ":". example:my-app:cool-cookie
Best regards, Daniel.