Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"$" dollar character prefixing cookies names

Tags:

c#

cookies

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:

enter image description here

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?

like image 853
auraham Avatar asked Feb 29 '12 22:02

auraham


1 Answers

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...

like image 190
Paul Kearney - pk Avatar answered Oct 18 '22 22:10

Paul Kearney - pk