访问完一个网页后,如何把这个网页的COOKIE删除呢?
解决方案 »
- windows桌面图标移动的效果如何用MFC实现?
- vc6.0中关于树控件的使用
- OCX控件替换的问题
- socket.connect()连上之后,怎么知道他以后的状态
- 奇怪的DEBUG和RELEASE问题?请教高手~偶是大一新生~
- 消息的接收问题
- 散,就是散,散到1400分了,NND
- 在线等待,帮帮忙!~!~
- 谁能用vc通过snmp实现一个arp.exe,就是查出自己的机器的arp talble,snmputil.c好像不太好使
- "System.AccessViolationException"类型未经处理的异常在CTestDlg.exe....请问这是什么错啊?
- 简单图像识别问题
- 关于ActiveX注册的问题
最好是在MSHTML的接口中直接删除的, 我查看了IHTMLDocument2接口,没查到相关的命令呀
Parametersp
Pointer to a variable of type BSTR that receives the name=value; pairs, plus any of the values listed in Possible Values.
v
BSTR that specifies the name=value; pairs, plus any of the values listed in Possible Values.
Possible Valuessecure; If you set a cookie as secure;, the stored cookie information can be accessed only from a secure environment.
expires=date; If you set no expiration date on a cookie, it expires when the browser closes. If you set an expiration date, the cookie is saved across browser sessions. If you set an expiration date in the past, the cookie is deleted. Use Greenwich Mean Time (GMT) format to specify the date.
domain=domainname; If you set the domain of the cookie, pages on a domain made up of more than one server can share cookie information.
path=path; If you set a path for the cookie, the current document can share cookie information with other pages within the same domain—that is, if the path is set to /thispathname, all pages in /thispathname and all pages in subfolders of /thispathname can access the same cookie information. 注意这句:If you set an expiration date in the past, the cookie is deleted.
调用put_cookie时,返回值是正确的,但是再次get_cookie,cookie中的内容并没有变,而且cookie也没有被删掉。 BSTR bstrCookie; HRESULT hr = E_FAIL;
CComPtr<IDispatch> spDispDoc;
hr = m_spBrowser->get_Document(&spDispDoc);
if (FAILED(hr) || !spDispDoc) return; CComQIPtr<IHTMLDocument2> spHtmlDoc = spDispDoc;
if (!spHtmlDoc) return;
hr = spHtmlDoc->get_cookie(&bstrCookie);
if (!spHtmlDoc) return;
CComBSTR bstrExpire;
CTime ct = CTime::GetCurrentTime();
bstrExpire = ct.FormatGmt(L"%c"); CComBSTR bstrPut = L"expires=";
bstrPut += bstrExpire;
hr = spHtmlDoc->put_cookie(bstrPut);
if (!spHtmlDoc) return;
hr = spHtmlDoc->get_cookie(&bstrCookie);
if (!spHtmlDoc) return;