spBrowser->Navigate
(
bstrURL,
&vtEmpty/*flags*/,
&vtEmpty/*frame*/,
&vtEmpty/*post data*/,
&vCookie/*headers*/
);
The cookie I set does not appear on the server. I assume that the
syntax I'm passing to the 'headers' argument of Navigate is incorrect,
but I see no documentation about exactly how to set 'headers'.
When I monitor the IE event BeforeNavigate2, it shows the 'header'
argument, which includes some garbled version of the characters I
put in vCookie.
Any help will be appreciated.
Thanks,
Paul Bradford
Thanks,
Sean Shi
Hi Sean,
That's an interesting article, but unfortunately it doesn't solve my
particular
problem. The article talks about setting a cookie in an ASP session
from code running on the server.
My problem is to set a cookie on a client before the HTTP GET takes
place, so that the ASP code will see the cookie. I'm pretty sure that
the 'headers' argument to IWebBrowser2::Navigate will let me
do this, but I can't figure out the syntax of the 'headers' argument.
Thanks,
Paul Bradford
The Headers is type of VT_BYREF | VT_VARIANT.
Also use network monitor to check whether the cookie is sent out.
I set a breakpoint in BeforeNavigate2 and look at Headers. It contains
some of the characters from the 'headers' parameter in my call to
IWebBrowser::Navigate, but it's all garbled. There is something
about my 'headers' parameter to Navigate that is not correct, but
I don't know what.
What exactly should the 'headers' argument to IWebBrowser2::Navigate
look like?
Paul
and the Headers type will be the same as the one in Navigate2.
VT_BYREF|VT_VARIANT.
You can say it is a pointer to a variant.
How about this in MFC for example:
CString strCookie;
COleVariant* pvarCookie = new COleVariant( strCookie );
Similar thing in ATL.
My question doesn't have to do with the type of the
'headers' argument, it has to do with the contents.
It is a string - how do I format it? I've tried lots
of variations of
"Cookie: foo=bar"
and none of them work. What exactly is the syntax?
cookie = "Cookie:" cookie-version
1*((";" | ",") cookie-value)
cookie-value = NAME "=" VALUE [";" path] [";" domain]
cookie-version = "$Version" "=" value
NAME = attr
VALUE = value
path = "$Path" "=" value
domain = "$Domain" "=" value
For example:
Cookie: $Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme"
$Version parameter is mandatory-- With best wishes, Igor Tandetnik
"Paul Bradford" <paulbr...@alum.mit.edu> wrote in message
news:9d9iud$sf9$1...@bob.news.rcn.net...
BSTR myBstr = SysAllocString("yourCookieString");
VARIANT varMyVariant;
varMyVariant..vt = VT_BSTR;
varMyVariant.bstrVal = myBstr;
let me know whether that helps.
Sean
In case anybody is interested, I went through Microsoft support
to find out more about this. Their answer: what I want to do is
not supported. The 'headers' argument to Navigate/Navigate2
CANNOT be used to set cookies. There is no way to set cookies
for an IWebBrowser2 object.
I consider this a bug, but what I think is unlikely to change anything :)
We solved my problem in a completely different way.
Sean Shi