title: How to set and get JSESSIONID cookie in VBA?
body: <p>I'm writing a VBA web service client in Excel 2010 using MSXML2.XMLHTTP60 for my Java REST web services hosted on Tomcat 8.5.5.</p>
  
  <p>In VBA, I want to snag the string <code>JSESSIONID=E4E7666024C56427645D65BEB49ADC11</code> from a response and set it in a subsequent request.<br>
  (if Excel crashes, it seems that this cookie is lost and the user has to authenticate again. I want to set the last stored session ID for the user, so if the session is still alive on the server, they don't have to re-authenticate in the Excel client.)</p>
  
  <p>I saw some online resources according to which the following will pull the JSESSIONID cookie, but the last line always prints empty:</p>
  
  <pre><code>Dim httpObj As New MSXML2.XMLHTTP60
  With httpObj
      .Open "POST", URL, False
      .SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
      .SetRequestHeader "Connection", "keep-alive"
      .Send
  End With
  Debug.Print "Response header Cookie: " &amp; httpObj.GetResponseHeader("Cookie")  'This should pull the JSESSIONID cookie but is empty
  </code></pre>
  
  <p>When I print <code>httpObj.GetAllResponseHeaders</code> I do not see any headers that hold JSESSIONID.</p>
  
  <p>In the same resources, the following should set the desired cookie, but it doesn't (I print out the headers of the incoming request on the server and see that my attempt did not override the JSESSIONID value).</p>
  
  <pre><code>httpObj.SetRequestHeader "Cookie", "JSESSIONID=blahblah"
  </code></pre>
  
  <p>I may be missing the mechanism for how JSESSIONED is transmitted, and how and when VBA pulls it and sets it.</p>