title: Retrieiving Cookies and Sending Cookies and Post Variables in VBScript
body: <p>I'm trying to submit some post data form using vbscript. The site I'm posting it to contains some java, and having poked around in the headers, I notice it's sending a cookie containing <code>JSESSIONID</code>, which I believe is to do with the java authentication:</p>
  
  <pre><code>Cookie: JSESSIONID=XXXXXXXXXXXXXXXXXXXXX
  </code></pre>
  
  <p>When I just send the address and the post data I want to send and look at the responsetext it's sent me back to the java authentication page, which makes me think I need to retrieve the jsessionid cookie and submit that back with the data as well.</p>
  
  <p>This is the function I'm using to submit the post data. For simple forms this seems to work fine, but the java on this page has kind of thrown me:</p>
  
  <pre><code>Function Fetch(URL, POST)
  
    Set WshShell = CreateObject("WScript.Shell")
    Set http = CreateObject("Microsoft.XmlHttp")
      http.open "POST", URL, FALSE
      http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      http.send POST
    Fetch = http.responseText
   set WshShell = nothing
   set http = nothing  
  
  End Function
  </code></pre>
  
  <p>My questions really are: am how doing this right? Do I need to load the first page, get the cookie and resubmit it back with the form? And if so, how do I retrieve the cookie that the server sends back in the header? I can see when I look in the headers that they sent back:</p>
  
  <pre><code>Set-Cookie: JSESSIONID=XXXXXXXXXXXXXXXXXXXXX; Path=/Page
  </code></pre>
  
  <p>Thanks very much.</p>