各位大哥好,小妹遇到麻烦,我现在用vc中的CInternetSession,GetHttpConnection,CHttpFile等类实现发送用户名和密码登陆一个网站,但是把接收到的内容存成html文件,打开一看,是说浏览器设置太安全级别高,不能写cookie,但是我看我的浏览器设置是正常的,我用浏览器打开网站登陆是没有问题的,然后我用工具抓包,发现浏览器发送的http头里面的Cookie项和程序发送的http头里面的Cookie项是不一样的,但是我不知道如何使我的http头里面的Cookie和浏览器里的Cookie一样,请高手指点!
感觉 InternetGetCookie 和 InternetSetCookie 没有想像中的好用,不知道为什么~
看看下面一个帖子,上次我贴上来得时候没有能贴上,这次试试
//URL is:http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20613677.html
Hi all,I need a bit of help processing multiple session cookies that are returned as part of the http response from the server. (NB: The actuall request/response is handled using the WinInet libraries.)Using the following command:HttpQueryInfo(hReq,HTTP_QUERY_RAW_HEADERS_CRLF, (LPVOID)lpOutBuffer,&dwSize,NULL)I have been able to view the response headers:HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Mon, 12 May 2003 15:51:43 GMT
Set-Cookie: SSLCRED=; path=/; expires=Wed, 13-Nov-2002 15:51:42 GMT; domain=.mydomain.com
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Set-Cookie: SMSESSION=********************************; path=/; domain=.mydomain.com
Cache-Control: private, max-age=0
Content-Type: text/html; charset=utf-8
Content-Length: 3518To return a cookie I have had to use the HttpQueryInfo in combination with the HTTP_QUERY_SET_COOKIE flag. This function will then only return the 1st cookie:SSLCRED=; path=/; expires=Wed, 13-Nov-2002 15:51:42 GMT; domain=.mydomain.comI have also tried to use the InternetGetCookie function but this always seems to return null.As such is it possible to enumerate through the rest of the cookies or does a method exist that would allow these cookies to be selected.Thanks in advance for any help,
MMak.