Reputation: 356
I'm having an issue when I make an ajax post from sub.mydomain.com to domain.com. I've set the cookie to be .mydomain.com and I know the session is being set properly because if I goto sub.mydomain.com in the browser the session id matches mydomain.com session id. However whenI do an ajax post from sub.mydomain.com to mydomain.com the session id changes.
To get around it I'm passing the session id in the post.
But I want to know why it's not working like its supposed to.
Any ideas would be helpful.
M
Upvotes: 0
Views: 994
Reputation: 97672
Cookies aren't sent in cross origin requests(which I assume you're using for sessions), in order to enable this you have to set withCredentials
on both the request an d response.
request xhr.withCredentials = true;
response header Access-Control-Allow-Credentials: true
Upvotes: 1