Wednesday, March 23, 2011

How does wininet handle cookies

I have a .NET client application that needs to communicate with a server using two distinct user credentials. Lets say that the application runs two threads. When start running, every thread sends the user & password to authenticate and the server in return stores a cookie on the http session. The subsequent calls send the authentication cookie and not the user credentials.

We have two cookies for the same process. How does wininet "knows" to send the appropriate cookie for each thread?

Does wininet manage the cookies collection per thread? per http session? per process?

Thanks

From stackoverflow
  • Wininet uses cookies per process.

    However in a .NET client you can use a Cookie container with the HttpWebRequest object.

    You create one cookie container for each "session". Assign the appropriate container to each HttpWebRequest when making the various requests for each session.

    LiorH : what you are saying that if my application will not perform special handling the default behavior would be to always send the last cookie recieved from the server. right?

0 comments:

Post a Comment