Microsoft KB Archive/234486

From BetaArchive Wiki
Knowledge Base


PRB: XMLHttpRequest setRequestHeader Method and Cookies

Article ID: 234486

Article Last Modified on 5/12/2003



APPLIES TO

  • Microsoft Internet Explorer 5.0
  • Microsoft Internet Explorer 5.5
  • Microsoft XML Core Services 4.0
  • Microsoft XML Parser 3.0 Service Pack 1
  • Microsoft XML Core Services 4.0



This article was previously published under Q234486

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"
                

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

REFERENCES

303207 INFO: Installation of MSXML Parser Affects Run Mode


Keywords: kbprb KB234486