Passing cookies and form data in XMLHTTP

Source: Internet
Author: User
Tags send cookies
cookie|xml| data

Here are some of the relatively complex applications. Using the appropriate method, you can pass cookies in XMLHTTP and submit the form.

These also remind us of the need to prevent the vulnerabilities that this method brings.

First, transfer form data to the server
Dim forminfo,objxmlhttp
forminfo= "user=niceidea&pw=111111"
Set objxmlhttp = Server.CreateObject ("Microsoft.XMLHTTP")
Objxmlhttp.open "POST", "http://niceidea.org/cmd.asp?...", False
Objxmlhttp.send FormInfo

When it comes to Chinese characters, you need to escape the function.
The Escape () function converts all characters to ASCII encoding.
forminfo= "User=niceidea&name=" &escape ("Chinese")

Niceidea signed a souvenir.

Second, send cookies
Dim cookie:cookie= "Waufhfggadua"
Set objxmlhttp = Server.CreateObject ("Microsoft.XMLHTTP")
Objxmlhttp.open "POST", "Http://www.niceidea.org/cmd.asp?act=vrs", False
Objxmlhttp.setrequestheader "cookies", cookies
Objxmlhttp.send

Third, get the header of the returned information (including cookie information)
@ codepage=65001
Response.AddHeader "Encoding", "Utf-8"
Set objxmlhttp = Server.CreateObject ("Microsoft.XMLHTTP")
Objxmlhttp.open "POST", "http://localhost/cookie.asp", False
Objxmlhttp.setrequestheader "cookies", cookies
Objxmlhttp.send
Response.Write (Objxmlhttp.getallresponseheaders ())


of which cookie.asp

Response.Cookies ("test") = "Test"


return Result:
Connection:keep-alive Date:fri, Mar 2006 20:07:13 GMT server:microsoft-iis/6.0 x-powered-by:asp.net Content-Length: 0 content-type:text/html Set-cookie:test=test; path=/cache-control:private



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.