||
在昨天的《使用正确版本的XMLHTTP》中卖了个关子,ServerXMLHTTP的功能比XMLHTTP强大,你现在大概已经猜到了吧。没错,用ServerXMLHTTP可以在HTTP请求头中加入Cookie,而XMLHTTP不可以。
为了方便测试,先写一个回显Cookie的简单的PHP程序:
<?php foreach($_COOKIE as $key => $value) echo "$key => $value\r\n"; ?>
然后分别用ServerXMLHTTP和XMLHTTP测试:
Dim http Set http = CreateObject("Msxml2.XMLHTTP") http.open "GET", "http://demon.tw/test/coo ", False http.SetRequestHeader "Cookie", "user=demon; passwd=123456" http.send WScript.Echo http.responseTextkie.php
用Msxml2.XMLHTTP什么都没有返回。
Dim http Set http = CreateObject("Msxml2.ServerXMLHTTP") http.open "GET", "http://demon.tw/test/coo ", False http.SetRequestHeader "Cookie", "user=demon; passwd=123456" http.send WScript.Echo http.responseTextkie.php
用Msxml2.ServerXMLHTTP返回
user => demon
passwd => 123456
以后碰到需要Cookie的网页就不用愁了。
晴云孤魂's Blog|就爱编程搜帖|手机版|Archiver|就爱编程论坛
GMT+8, 2025-7-2 01:16 , Processed in 0.171659 second(s), 26 queries .
Powered by Discuz! X2
© 2001-2011 Comsenz Inc.