Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpWebResponse.Cookies empty despite Set-Cookie Header (no-redirect)
    primarykey
    data
    text
    <p>I'm struggling to figure out what is wrong here. I'm sending login information, I can see the Set-Cookie in the Header with the correct value, but the Cookies collection is not getting filled.</p> <p>This is HTTPS, the login auto-redirects, but I disabled it with AllowAutoRedirect=false to try to troubleshoot this issue.</p> <p>In this screenshot, you can easily see the debug information and that the cookie should be getting set. I am setting my httpWebRequest.Cookie to a new CookieCollection.</p> <p><img src="https://i.stack.imgur.com/Gydx7.png" alt="Right click and select view image to see full-size."></p> <pre><code>HttpWebRequest httpRequest; CookieContainer reqCookies = new CookieContainer(); string url = "https://example.com"; string[] email = user.Split('@'); email[0] = System.Web.HttpUtility.UrlEncode(email[0]); user = email[0] + "@" + email[1]; pass = System.Web.HttpUtility.UrlEncode(pass); string postData = "email=" + user + "&amp;password=" + pass; byte[] byteData = Encoding.UTF8.GetBytes(postData); httpRequest = (HttpWebRequest)WebRequest.Create(url); httpRequest.Method = "POST"; httpRequest.Referer = url; httpRequest.CookieContainer = reqCookies; httpRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1003.1 Safari/535.19"; httpRequest.Accept = "text/html, application/xhtml+xml, */*"; httpRequest.ContentType = "application/x-www-form-urlencoded"; httpRequest.ContentLength = byteData.Length; using (Stream postStream = httpRequest.GetRequestStream()) { postStream.Write(byteData, 0, byteData.Length); postStream.Close(); } httpRequest.AllowAutoRedirect = false; HttpWebResponse b = (HttpWebResponse)httpRequest.GetResponse(); </code></pre> <p>Tried the exact same code connecting to <a href="http://www.yahoo.com" rel="noreferrer">http://www.yahoo.com</a> and the cookies are put into my collection... Argh...</p> <p>Here is the Set-Cookie Header value:</p> <blockquote> <p>s=541E2101-B768-45C8-B814-34A00525E50F; Domain=example.com; Path=/; Version=1</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload