Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Can't send cookies using XMLHTTP

Reply
Thread Tools

Can't send cookies using XMLHTTP

 
 
Lu Wei
Guest
Posts: n/a
 
      08-07-2006
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...;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

--
Regards
Lu Wei
 
Reply With Quote
 
 
 
 
Lu Wei
Guest
Posts: n/a
 
      08-13-2006
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.
--
Regards
Lu Wei
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send XMLHTTP object from a button input jr Javascript 6 08-01-2010 03:53 PM
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
Msxml*.XMLHTTP vs. Microsoft.XMLHTTP yawnmoth Javascript 11 11-09-2006 08:44 PM
Msxml2.XMLHTTP object's send method throwing HTTP /1.1 405 - Method not allowed error. RK Javascript 5 08-08-2004 08:52 PM
XMLHTTP SEND and 0x800C0005 error kenny ASP General 2 01-29-2004 02:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57