question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

to avoid issues with cookie strings with ; and stuff.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dougwilsoncommented, May 13, 2014

The answer is they are URL-encoded, or not. It’s up to the server, as cookie values are opaque ASCII values (see RFC 2965). The server just has to encode it the same way it wants to receive the value; the client does not do anything with the value. I’ve only seen servers encoding into UTF-8 and escaping the values (with, for example, escape or encodeURIComponent).

But yea, this module could certainly base64-encode the values or URL-encode the values, as long as it decodes them in the same way 😄

0reactions
robpavezacommented, Jul 29, 2016

@dougwilson I did some additional research. RFC2109 specifies this grammar:

 The two state management headers, Set-Cookie and Cookie, have common
 syntactic properties involving attribute-value pairs.  The following
 grammar uses the notation, and tokens DIGIT (decimal digits) and
 token (informally, a sequence of non-special, non-white space
 characters) from the HTTP/1.1 specification [RFC 2068] to describe
 their syntax.

 av-pairs        =       av-pair *(";" av-pair)
 av-pair         =       attr ["=" value]        ; optional value
 attr            =       token
 value           =       word
 word            =       token | quoted-string

You’ll note it calls out “token” as from HTTP/1.1, which states this:

      token          = 1*<any CHAR except CTLs or tspecials>

      tspecials      = "(" | ")" | "<" | ">" | "@"
                     | "," | ";" | ":" | "\" | <">
                     | "/" | "[" | "]" | "?" | "="
                     | "{" | "}" | SP | HT

Therefore base64-encoded values when they include “=” need to be quoted strings or URL-encoded. I would recommend always using quoted-strings as that seems like it should always work for a conforming client.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Base64 Encoding of "cookies" - Online
Encode cookies to Base64 format with various advanced options. Our site has an easy to use online tool to convert your data.
Read more >
Cookie encoding Base64 - Stack Overflow
Cookies can be base64 encode. So if I capture pcap, does there any way, I can tell that cookie is base64 encoded? The...
Read more >
Online Tool | Encode: cookie - Base64 Encode
Basically, Base64 is a collection of related encoding designs which represent the binary information in ASCII format by converting it into a base64...
Read more >
Cookies are always base64 and JSON encoded #158 - GitHub
At present, the cookie utilities always encode (and expect to decode) a base64, JSON value, using the encodeCookieValue/decodeCookieValue functions.
Read more >
How to modify a Base64 encoded cookie? - Google Groups
I was doing a test on a website and noticed that the cookie set by it can be Base64 decoded. And upon decoding...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found