title: Get response header jquery ajax post Set-Cookie
body: <p>I am using YouTrack for our tracking system. Youtrack comes with a rest webservice that you can call to get information from the system. I am having problem getting authorized and is getting forbidden all the time.</p>
  
  <p>I do my post to their login, and I get the "login ok" respone, and if I check in firebug I can see that the headers are set correctly, but the cookie does not get created. For that I need to get the value from the response header, Set-Cookie.</p>
  
  <p>The post looks like this.</p>
  
  <pre><code>      $.post(youTrackLoginUrl, { login: "restUser", password: "qwerty" }, function(data, text, xhr) {
  
        // do something 
  
        });
  </code></pre>
  
  <p>And the response and request looks like this.</p>
  
  <p>Response headers:</p>
  
  <blockquote>
    <p>HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Set-Cookie: YTJSESSIONID=91541168A3E0FF9BBB02A8D427D70127; Path=/
    jetbrains.charisma.main.security.PRINCIPAL=NjVlODRiZTMzNTMyZmI3ODRjNDgxMjk2NzVmOWVmZjNhNjgyYjI3MTY4YzBlYTc0NGIyY2Y1OGVlMDIzMzdjNTpyZXN0VXNlcg; Expires=Wed, 09-Oct-2013 09:47:48 GMT; Path=/
    Cache-Control: no-cache, no-store, no-transform, must-revalidate
    Access-Control-Allow-Origin: a.domain.com
    Access-Control-Allow-Credentials: true
    Content-Type: application/xml;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Tue, 09 Oct 2012 09:47:48 GMT</p>
  </blockquote>
  
  <p>Request:</p>
  
  <blockquote>
    <p>POST /rest/user/login HTTP/1.1
    Host: b.eelab.se
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
    Accept: <em>/</em>
    Accept-Language: sv-se,sv;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    Referer: <a href="http://intra.eelab.se/kontakt/it-vad-jobbar-vi-pa-nu/">http://intra.eelab.se/kontakt/it-vad-jobbar-vi-pa-nu/</a>
    Content-Length: 30
    Origin: <a href="http://a.domain.com">http://a.domain.com</a>
    Pragma: no-cache
    Cache-Control: no-cache</p>
  </blockquote>
  
  <p>I need the Set-Cookie value to create the cookie on the site. What can I do to achive this?</p>
  
  <p>/Cheers.</p>