简体   繁体   中英

Making a client-side HTTP GET request with cookies in Javascript or any other language

In a web page that I'm developing (using asp.net, but that is not relevant to this question I think) I have the necessity of making an HTTP GET request to an external website.

The two problems I have are these:

1) The request must be made client-side, because the website I'm making the request to restricts access to only certain IP addresses. My client will be in the range of accepted IPs, but my server will not, so the request must be made by the client using some kind of client-side script (Javascript or other, suggestions are welcome)

2) The request must include a cookie for the external site with a certain value that I must set, so the method/library/script that makes the request must allow me to set a cookie

I searched on SO and other sites but I'm having little luck, the few examples I found don't seem to work. Any idea in any client-side language is much appreciated.

With jQuery you can send and HTTP GET request in a really simple way, chek this reference

Something like:

$.get( "test.php", { your_cookie_value: "111111" } );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM