To facilitate the test, first write a simple PHP program for ECHO Cookie:
Copy codeThe Code is as follows: <? Php
Foreach ($ _ COOKIE as $ key => $ value)
Echo "$ key => $ value \ r \ n ";
?>
Then use ServerXMLHTTP and XMLHTTP to test:Copy codeThe Code is as follows: Dim http
Set http = CreateObject ("Msxml2.XMLHTTP ")
Http. open "GET", "http://demon.tw/test/cookie.php", False
Http. SetRequestHeader "Cookie", "user = demon; passwd = 123456"
Http. send
WScript. Echo http. responseText
Msxml2.XMLHTTP does not return anything.Copy codeThe Code is as follows: Dim http
Set http = CreateObject ("Msxml2.ServerXMLHTTP ")
Http. open "GET", "http://demon.tw/test/cookie.php", False
Http. SetRequestHeader "Cookie", "user = demon; passwd = 123456"
Http. send
WScript. Echo http. responseText
Returned with Msxml2.ServerXMLHTTP
User => demon
Passswd => 123456
You don't need to worry about the web pages that require cookies in the future.
Original article: http://demon.tw/programming/vbs-http-cookie.html