Reputation: 11538
We have website > main.example.com
We have a mobile site > mobile.example.com
Our cookie domain is > .example.com
Our mobile website is a client-side (backbone) heavy app which only makes $.ajax to our main website.
Now Safari and Chrome both do not send the cookie alongside ajax requests. I can see the cookie is stored in the storage using developer tools but the browsers fail to recognize and doesn't include them in requests.
Any ideas?
Upvotes: 1
Views: 1676
Reputation: 1198
I had this trouble a few month back developing site that uses backbone.js and consumes a restful api via cors. I learned that cors request do not send the cookies by default, you have to tell javascript to send it in the request as well.
All you have to do is pass the xhrfields with your options to $.ajax request
xhrFields: {withCredentials: true}
Upvotes: 1