Sending a WebRequest and Saving/Using Cookies RRS feed

  • General discussion

  • I am working on an application that I am trying to get working that requires me to save the cookie result/session after visiting the initial page. I can't seem to get this to work using a HttpWebRequest example I saw, and I am wondering if there's another way.

    The idea I am going for is this:

    1. Visit the 'login page', and send post results (not real authentication, just confirming age, so a few drop-boxes)
    2. Receive authenticated page, which now has the cookie, and save it
    3. Use the cookie in the next request, which requires that we've sent a valid age.

    Is there an example you know if that shows a simple way to save and reuse a cookie?

    Thursday, December 9, 2010 10:13 PM

All replies

  • Look up System.Net.CookieContainer it'll have an example how to reuse cookie across web requests. I'm doing it right now, but there seem to be a bug in the CookieContainer, it selectively drops cookies or not send them out on subsequent requests. Still looking at why this happens.
    Friday, December 10, 2010 4:16 AM