WinHttp maintains session using handle returned by WinHttpConnect ( ).
How does it internally maintain the session ??
Does it use cookies ?? If yes then it must set cookie in every sub
sequent request of that session.
Can we disable this cookie ?? If Yes, then how can we do this ??
Thanks,
Manjiri
WinHTTP itself does not require cookies for anything, but it does support
them. Cookies received (via the Set-Cookie response header) from a server
will be stored in the corresponding WinHTTP session object. The session
object is represented by the handle returned from the WinHttpOpen function,
which is the parent of a Connect handle returned from WinHttpConnect. On
subsequent requests made within the context of that WinHTTP session, WinHTTP
will resend any cookies if the conditions are right (host name, domain and
path match and the cookie is not expired, etc.).
After sending a request using WinHTTP and receiving a response, you can see
what cookies the server sent back by querying the value of the "Set-Cookie"
response header.
Some similar questions to yours about WinHTTP cookie handling were posted
about a month ago in this newsgroup, so I'll repost those:
> 1. Can I Maintain two different Web Sessions (for same web server) in two
> different instances of WinHTTTPRequest? If YES then how many simultaneuos
> connection can i have with a Web Server (WinInet restricts for not more
than
> four http://support.microsoft.com/support/kb/articles/Q183/1/10.ASP)
Yes, each WinHTTPRequest object instance has its own separate WinHTTP
session. A WinHTTP session manages resources that are typically per-user,
such as cookies and authenticated connections. So each WinHTTPRequest object
has its own cookie database.
By default, WinHTTP imposes no limits on the number of simultaneous
connections, unlike WinInet. You can create as many connections as the
target server will allow.
> 2. How does WinHTTPRequest handle cookies that are sent by WebServer meant
> to reside on User's machine (ie with Expiry date greater than the request
> date). Does it saves it to the default cookies database or keep them in
> memory? Is this memory shared among WinHTTPRequest instances or is it
> instance specific.
> (Somewhat like my query no. 1)
In WinHTTP, cookies are stored in-memory only, they are never persisted to
disk. Therefore, all cookies are treated as 'session' cookies. When a
WinHTTPRequest object (or WinHTTP session) is destroyed, all the cookies in
its private cookie store are deleted. If a cookie expires before the WinHTTP
session is destroyed, then the cookie is discarded (so expiry timestamps are
still honored). Cookies are not shared across WinHTTPRequest object
instances.
> 3. Can I enable/disable storing Cookies in the default cookies database
> using VB?. I Know I can do that by using WinInet, But here I didn't find
> that. Whereas document states that It can be done in VC++ by using WinHTTP
> API's.
There is no concept of a default cookie database in WinHTTP. Each WinHTTP
session has its own private cookie database. Using the WinHTTPRequest
component, there is no way to disable cookie support. However, cookie
support can be disabled on a per-session basis using the WinHTTP Win32 API,
by using WinHttpSetOption with the WINHTTP_OPTION_DISABLE_FEATURE option,
specifying the
WINHTTP_DISABLE_COOKIES flag.
Hope that helps.
Regards,
Stephen Sulzer
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.
"Manjiri" <mkon...@firstrain.com> wrote in message
news:uMYb7uJXBHA.1632@tkmsftngp05...
Regards
Venkat
.
"Stephen Sulzer (Microsoft)" <anti-sp...@microsoft.com> wrote in message
news:eK6q4CSXBHA.716@tkmsftngp05...