How does wininet handle cookies

六月ゝ 毕业季﹏ 提交于 2019-12-13 20:24:18

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/443567/how-does-wininet-handle-cookies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!