How to get and pass cookies.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kevinyy
    New Member
    • Jul 2008
    • 77

    How to get and pass cookies.

    I'm working on a proxy and i was wondering how i can collect the cookies and pass them back to the client? so they can log into sites and etc? here is my http receive code and pass the info back:
    Code:
    System.Net.Configuration.HttpWebRequestElement wr = new System.Net.Configuration.HttpWebRequestElement();
    wr.UseUnsafeHeaderParsing = true;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    CookieContainer cookieContainer = new CookieContainer();
    request.CookieContainer = cookieContainer;
    request.CookieContainer.Add(cookieContainer.GetCookies((Uri)url));
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Stream responsestream = response.GetResponseStream();
    byte[] buffer = new byte[bz];
    rebu = responsestream.Read(buffer, 0, bz);
    while (rebu != 0)
    {
        soket.Send(buffer, rebu, 0);
        rebu = responsestream.Read(buffer, 0, bz);
    }
    how can i gather the cookies and pass them back?
    -Thanks

    C#.Net3.5
  • Kevinyy
    New Member
    • Jul 2008
    • 77

    #2
    Can anyone help? I have not yet resolved this problem

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      You can use the Request.Cookies collection to retrieve cookies.

      As for passing them along......I'm not sure what you're trying to do.

      -Frinny

      Comment

      • Kevinyy
        New Member
        • Jul 2008
        • 77

        #4
        Originally posted by Frinavale
        You can use the Request.Cookies collection to retrieve cookies.

        As for passing them along......I'm not sure what you're trying to do.

        -Frinny
        im writing a cookie compliant proxy.

        Comment

        Working...