Here is a straightforward jQuery AJAX POST code snippet:
$.ajax({
type: "POST",
url: AppConstants.URLs.PROXY,
data: message,
xhrFields: {
withCredentials: true
},
success: function(data, status, xhr) {
console.log("Cookie: " + xhr.getResponseHeader("Set-Cookie"));
}
});
I am looking to retrieve the cookie and store it using cookies-js.
However, as stated in the documentation at http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders%28%29-method:
- Return all response headers, excluding headers that are a case-insensitive match for Set-Cookie or Set-Cookie2, as a single string, with each header line separated by a U+000D CR U+000A LF pair, excluding the status line, and with each header name and header value separated by a U+003A COLON U+0020 SPACE pair.
Despite seeing "Set-Cookie" in the Response headers in Chrome's Network tool, I have confirmed the presence of the "Set-Cookie" header using curl
as well.
Could you please guide me on how to save the cookie in my front-end application? Additionally, note that my application operates solely on https.
If more information is needed, I'd be happy to provide it upon request.