How to get a cookie from an AJAX response?
ajax, google-chrome, html, jquery
Solution
You're looking for a response header of `Set-Cookie`:
xhr.getResponseHeader('Set-Cookie');
It won't work with HTTPOnly cookies though.
Update
According to the XMLHttpRequest Level 1 and XMLHttpRequest Level 2, this particular response headers falls under the "forbidden" response headers that you can obtain using `getResponseHeader()`, so the only reason why this could work is basically a "naughty" browser.
Problem
I have a `$.ajax` request on the same domain and I want to read the cookie. It keeps returning `null`. ``` $.ajax({ type: 'GET', url: myUrl, success: function(output, status, xhr) { alert(xhr.getResponseHeader("MyCookie")); }, cache: false }); ``` Any ideas? I'm using Chrome for this.