I have this function to retreive response cookies in a CookieContainer (this.cookies)
private void getCookies(string url)
{
// request
HttpWebRequest request = CreateWebRequestObject(url);
request.CookieContainer = this.cookies;
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Accept-Language", " es-MX,es;q=0.8,en-us;q=0.5,en;q=0.3");
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Method = "GET";
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
// response
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
foreach (Cookie c in response.Cookies)
{
this.cookies.Add(new Cookie(c.Name, c.Value, c.Path, c.Domain));
}
}
}
But, when I debug the request in Fiddler, I get this:
Why there is a "$" in cookies?
According MSDN
public Cookie( string name, string value, string path, string domain )
name Type: System.String The name of a Cookie. The following characters must not be used inside name: equal sign, semicolon, comma, newline (\n), return (\r), tab (\t), and space character. The dollar sign character ("$") cannot be the first character.
How can I remove this character?
The $ you see is not the name of the cookie; it is an attribute associated with a cookie.
RFC 2109 deals with HTTP state management; section 4.4 specifically deals with the dollar sign prefix. Hope that helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With