Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookies and xml 1

Status
Not open for further replies.

jslmvl

Vendor
Jan 26, 2008
268
GB
Hi,

In test1.asp, I set a cookies something like
<%
Response.Cookies("username")="mmmm"

url = Request.ServerVariables("URL")
n = instrrev(url, "/")
url = " & Request.ServerVariables("SERVER_NAME") & left(url, n) & "test2.asp"
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "get", url, true
xml.Send
Set xml = Nothing
%>
In test2.asp, I tried to get the cookies without success:
<%
username=request.Cookies("username")

Set fso = Server.CreateObject("Scripting.FileSystemObject")
outFilePath = Server.MapPath("test.txt")
Set textS = fso_OpenTextFile(outFilePath, 2)
textS.Write("username=" & username)
textS.Close()
Set textS = Nothing
Set fso = Nothing
%>
That is, in the file test.txt I only got "username=" without "mmmm"
Is this a bug or something wrong I did?

Thank you in advance.
 
[tt]Set xml = Server.CreateObject("[red]Msxml2.ServerXMLHTTP[/red]")
[blue]xml.SetRequestHeader "Cookie", "username=mmmm"[/blue]
xml.Open "get", url, true '[green]false if you need response[/green]
xml.Send[/tt]
 
Thank you tsuji!

Shoul we use Msxml2.ServerXMLHTTP instead of Microsoft.XMLHTTP?
 
Thanks.

Is Microsoft.XMLHTTP the older version of Msxml2.ServerXMLHTTP?
 
Yes or no. I think there is a considerable portion of re-write, notably on threading model, supporting scope and bug-fixing... which differentiate msxml2.serverxmlhttp from msxml2.xmlhttp. As to microsoft.xmlhttp, yes, that's much more dated in a sense and should be in favor of msxml2.xmlhttp at least.
 
I have just tried
Set xml = Server.CreateObject("Msxml2.ServerXMLHTTP")
xml.SetRequestHeader "Cookie", "username=mmmm"
but got
Unspecified error
for
xml.SetRequestHeader "Cookie", "username=mmmm
 
The other question that I missed during drafting up of the last post: they are different methods. Apart from the different size limits, one passes in the header, the other in the body. Sure querystring is more visible and has more capacity/size, the other more cryptic and why should the other-side be ready to read cookie in general except there is a two-way effort to agree upon beforehand? Hence, it is only more apt in talk server-to-server between intimately related parties. In any case, if any communication be passed in the header be welcome or encouraged from a tier party, it should be published to let known, like webservice. Otherwise, it cannot help taking on a hacking flavor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top