Skip to content Skip to sidebar Skip to footer

Storing Referrer Url In Cookie

I want to store several name value pairs in a single cookie on the client. One of those name value pairs is the document referrer. I am not sure what characters I can expect to fin

Solution 1:

You might not be able to "rely on the tilde character being encoded as %7E" but you can certainly store it that way in the cookie by replacing all ~ with %7E

Solution 2:

NOTE: Cookies cant have spaces, so my answer is invalid. thanks user649650.

You could use the ~ character in a way that might never be stored in a URL. A space will always be encoded as %20 you could use "~ " as the delimeter

my_cookie=a~ 1|b~ 2|c~ 3|referrer~ http://www.google.com/search?q=the~middle

would handle this case

my_cookie=a~ 1|b~ 2|c~ 3|referrer~ http://www.google.com/search?q=the~%20middle

Post a Comment for "Storing Referrer Url In Cookie"