Click to See Complete Forum and Search --> : How to write a cookie value with '&' in it.


JetDeveloper
May 16th, 2005, 03:44 PM
Since cookie values are separated by the &, how do you write a cookie which has an '&' in the value? I need to know how to escape the '&'.

Thank you.

jamessadlier
May 17th, 2005, 06:33 AM
Maybe Server.HtmlEncode the value?

I would've though that assigning ...

HttpCookie cookie;
cookie.Value = "blahblah&blah";

... would have done it anyway though.

JetDeveloper
May 17th, 2005, 12:36 PM
The problem is I'm trying to do store sites that have query strings in the URL.

Cookies with multi-values are stored

Key1=val1&Key2=val2, etc.

If val2 is someurl.aspx?a=1&b=2, it only stores the value up to

'someurl.aspx?a=1'

Then it thinks that the '&b=2' is another value

jamessadlier
May 18th, 2005, 10:23 AM
Well, without knowing the actual solution you could always replace the & in a string with your own specific marker that a URL could not contain, say "*amp*", and replace it back when you read it?