I am doing a post from my frontend to a backend on another domain to create a session with AJAX.
//create a user session (asynchronously)
$.ajax({
method: "POST",
url: api_url + "/sessions",
dataType: 'text'
})
.done(function(sessionid) {
console.log('Sessionid: ', sessionid);
alert("Session created: " + sessionid);
});
return;
The server responds with a cookie in the response headers:
Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin:*
Allow: POST
Cache-Control:no-cache, must-revalidate
Connection:keep-alive
Content-Type:text/plain
Date:Tue, 23 Jun 2015 08:49:11 GMT
Expires:Sat, 26 Jul 1997 05:00:00 GMT
set-cookie:myCookie=s%3A6eb8444b-48dd-4084-91aa-3cf14c029b30.c0vbfPAvk6IkAlUE3nGXLEP3p09FDZejokgLyl5KifA; Path=/api; Expires=Sat, 05 Sep 2015 23:12:35 GMT
When I check the resources tab of my browser, I see that this cookie is not being set. How do I get this cookie to be set?
UPDATE:
I added this to the jQuery AJAX request:
xhrFields: {
withCredentials: true
}
I can now see that the request is including a Cookie header and that only one session is stored on the server. So it's working as intended.
However, I still do not see the cookie in the resources tab.