Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How do I persist cookies between multiple HttpWebRequest sessions?

How do I persist cookies between multiple HttpWebRequest sessions?

Scheduled Pinned Locked Moved C#
helptutorialquestioncom
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    god hacks
    wrote on last edited by
    #1

    The blow code is one of the 4 billion different tries of mine to get this working without help. The cookies just don't work. The session is not persistent because it doesn't send the original cookies with the next request. I've read that sometimes they get jumbled because of issues with maybe a comma in the cookie, but I have no idea if that is the problem or how to fix it...
    CookieContainer CC = new CookieContainer(); //First HttpWebRequest HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com"); request.CookieContainer = CC; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); CC.Add(response.Cookies); //Second HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com"); request.CookieContainer = CC; HttpWebResponse response2 = (HttpWebResponse)request.GetResponse();

    G 1 Reply Last reply
    0
    • G god hacks

      The blow code is one of the 4 billion different tries of mine to get this working without help. The cookies just don't work. The session is not persistent because it doesn't send the original cookies with the next request. I've read that sometimes they get jumbled because of issues with maybe a comma in the cookie, but I have no idea if that is the problem or how to fix it...
      CookieContainer CC = new CookieContainer(); //First HttpWebRequest HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com"); request.CookieContainer = CC; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); CC.Add(response.Cookies); //Second HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com"); request.CookieContainer = CC; HttpWebResponse response2 = (HttpWebResponse)request.GetResponse();

      G Offline
      G Offline
      god hacks
      wrote on last edited by
      #2

      Can anybody help me at all?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups