Can't send cookies using XMLHTTP

L

Lu Wei

Hello,

I'm writing a script to send posts to a web forum. I find that
MSXML2.XMLHTTP object could communicate with web server but I can't make
it send cookie which is needed for post authentication. I have searched
google and read some articles including:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q290899
http://support.microsoft.com/kb/234486/en-us

But setting the cookie twice as suggested didn't work. Here is my script:

//log in
var site="bbs.nju.edu.cn";
var body="login string"
var xmlhttp = WScript.CreateObject("MSXML2.XMLHTTP")
xmlhttp.open("POST","http://"+site+"/bbslogin?type=2", false);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(body);
WScript.Echo(xmlhttp.responseText); // log in will succeed

//post request
var _U_NUM, _U_UID, _U_KEY; //cookie names
....// assign values returned by login process to cookie names
xmlhttp.open("GET","http://"+site+"/bbspst?board=test", false);
xmlhttp.setRequestHeader("Cookie", "_U_NUM="+_U_NUM+";
_U_UID="+_U_UID+"; _U_KEY="+_U_KEY+"; FOOTKEY=;");
xmlhttp.setRequestHeader("Cookie", "_U_NUM="+_U_NUM+";
_U_UID="+_U_UID+"; _U_KEY="+_U_KEY+"; FOOTKEY=;");
xmlhttp.send();
WScript.Echo(xmlhttp.responseText); // this request will fail

I used ethereal and confirmed that no "Cookie:" header is sent. Could it
really be done by javascript to post articles to a web forum? What else
could I do? Any help is appreciated.

Some system info: win98se, WSH5.6, msxml.dll version is 8.0.6730.0
 
L

Lu Wei

More readings have convinced me that this is a "known" problem exists
with xmlhttp in msxml 3 and 4.

So, could anybody tell me how to post to web (with customized http
cookie header) through javascript (not in a browser but in WSH)? And
better it could be executed in win98se.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top