添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Tento prohlížeč se už nepodporuje.

Upgradujte na Microsoft Edge, abyste mohli využívat nejnovější funkce, aktualizace zabezpečení a technickou podporu.

Stáhnout Microsoft Edge Další informace o Internet Exploreru a Microsoft Edgi

V tomto článku

This article helps you resolve the problem when you use XMLHttpRequest setRequestHeader method and Cookies.

Original product version: Internet Information Services
Original KB number: 234486

Symptoms

When using the XML Document Object Model (DOM), the setRequestHeader method on the XMLHttpRequest object does not seem to set cookie headers as expected. The first call to setRequestHeader using the Cookie HTTP header seems to have no effect.

Resolution

To add cookies to the request, the call to setRequestHeader for the Cookie header must be repeated because the first call is ignored:

'this value is ignored, but the step is necessary
xmlRequest.setRequestHeader "Cookie", "any non-empty string here"
'set all cookies here
xmlRequest.setRequestHeader "Cookie", "cookie1=value1; cookie2=value2"

Setting cookies in this manner is atypical. Cookies are best set by the server using the Set-Cookie header.