Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

State Management(Cookies) In WinHTTPRequest??

712 views
Skip to first unread message

Rajeev Datta

unread,
Sep 15, 2001, 11:16:52 AM9/15/01
to
Developement Environment: VB 6
=======================

There is not much documentation about handling Cookies in WinHTTPRequest. I
have following queries:

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)

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)

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.

4. I'm unable to send cookies in the header by using SetRequestHeader. Is it
by design? If not then how can I do that. I'm using
objHTTPReq.SetRequestHeader "Cookie", "1=2; 3=4;"


Thanks in Advance

Rajeev Datta


Stephen Sulzer (Microsoft)

unread,
Sep 17, 2001, 3:04:22 PM9/17/01
to
Excellent questions.


> 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 the WINHTTP_OPTION_DISABLE_FEATURE option with the
WINHTTP_DISABLE_COOKIES flag.


> 4. I'm unable to send cookies in the header by using SetRequestHeader. Is
it
> by design? If not then how can I do that. I'm using
> objHTTPReq.SetRequestHeader "Cookie", "1=2; 3=4;"

There was a bug in which setting your own Cookie request header would not
work properly. But have you tried the August 2001 Technology Preview
release? This bug should be fixed in the August release.

http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/ms
dn-files/027/001/655/msdncompositedoc.xml


Regards,

Stephen Sulzer
Microsoft Corporation


"Rajeev Datta" <rajee...@hotmail.com> wrote in message
news:e6W29lfPBHA.1652@tkmsftngp03...

Rajeev Datta

unread,
Sep 18, 2001, 1:37:22 AM9/18/01
to
Thanks a lot Stephen,

That really solved a lot of my problems. Now I can think of, not just think
but definitely switch over to WinHTTP from WinInet.

Thanks once again

Rajeev Datta


"Stephen Sulzer (Microsoft)" <anti-sp...@microsoft.com> wrote in message
news:uW3lQu6PBHA.1416@tkmsftngp05...

0 new messages