After logging in via $.ajax()
to a site, I am trying to send a second $.ajax()
request to that site - but when I check the headers sent using FireB
Adding my scenario and solution in case it helps someone else. I encountered similar case when using RESTful APIs. My Web server hosting HTML/Script/CSS files and Application Server exposing APIs were hosted on same domain. However the path was different.
web server - mydomain/webpages/abc.html
used abc.js which set cookie named mycookie
app server - mydomain/webapis/servicename.
to which api calls were made
I was expecting the cookie in mydomain/webapis/servicename and tried reading it but it was not being sent. After reading comment from the answer, I checked in browser's development tool that mycookie's path was set to "/webpages" and hence not available in service call to
mydomain/webapis/servicename
So While setting cookie from jquery, this is what I did -
$.cookie("mycookie","mayvalue",{**path:'/'**});