I have a jQuery ajax call across a subdomain that works correctly except it’s not sending the cookie. Is there any way to accomplish this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This sounds like expected behavior to me. Cookies are per domain (and that includes subdomains). But I think you can force it with something like this:
This is totally untested so let me know if it works 😉
EDIT:
There is an alternative solution available using:
Check here: How do I SET a Cookie (header) with XMLHttpRequest in JavaScript?.
Also, you can set the cookies in PHP so that they are valid across all your subdomains. Something like this:
Note the ‘.’ before the domain – that will set the cookie for example.com and all its subdomains.
You can set session.cookie_domain in your app using the above or set it in your php.ini.
The above is stolen from here.