Following code works
var xmlhttp=new XMLHttpRequest();
xmlhttp.setRequestHeader('Cookie1',Value);
But when I change it to
var xmlhttp=new XMLHttpRequest();
xmlhttp.setRequestHeader('Cookie',Value);
The browser just ignore the command. I need to send header named 'Cookie' for a API. How can I achieve this?
It fails because the Cookie
header has a predefined meaning. It's for browser cookies. You can't set it explicitly.
It seems unlikely that an API is asking you to send a request header called Cookie
. Perhaps you're meant to actually send a cookie (which can you can do via document.cookie
).
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.