1
Reply

Cookies work with some host but not with others

Reiner Suikat

Reiner Suikat

Dec 3 2008 5:53 AM
2.2k

Hi all,

I'm trying to get a program to log into a server (amazon) with my own credentials to automate some bookkeeping tasks. But the cookies returned from Amazon never end up in the cookie container.

Here is the code sniplet:

CookieContainer Cookies = new CookieContainer(); //Objekt in dem das empfangene Cookie abgelegt wird

HttpWebRequest request0 = (HttpWebRequest)WebRequest.Create("https://www.amazon.de/gp/sign-in.html");

request0.CookieContainer = Cookies;

HttpWebResponse response = (HttpWebResponse)request0.GetResponse();

While the header of the response clearly contains Set-Cookie directives, these don't end up in the cookie container. If I try another url, e.g. http://www.crumhorn-labs/forum,  then the cookies end up in the container.

What could be the problem here? I really need this to work! I already tried to work around by reading the cookies of the header and adding them to the container manually, the next server response I need from amazon has two separate set-cookie directives and for some reason only one of them shows up in the header of the response, so the cookies actually get lost.

Any help is greatly appreciated

Thanks

Reiner


Answers (1)
Next Recommended Forum