I have two webapps WebApp1 and WebApp2 in two different domains.
- I am setting a cookie in WebApp1 in the HttpResponse.
- How to read the same cookie from HttpRequest in WebApp2?
I know it sounds weird because cookies are specific to a given domain, and we can't access them from different domains; I've however heard of CROSS-DOMAIN cookies which can be shared across multiple webapps. How to implement this requirement using CROSS-DOMAIN cookies?
Note: I am trying this with J2EE webapps
Best Answer
Yes, it is absolutely possible to get the cookie from domain1.com by domain2.com. I had the same problem for a social plugin of my social network, and after a day of research I found the solution.
First, on the server side you need to have the following headers:
Within the PHP-file you can use
$_COOKIE[name]
Second, on the client side:
Within your ajax request you need to include 2 parameters
Example: