-1

On a site which is hosted on *.x.com, I am loading a javascript (say javascriptY) from *.y.com. I have some cookie "name=value" stored on *.y.com (some user might have visited *.y.com earlier) and I want to read "name" cookie from the javascriptY which is loaded on *.x.com.

Is there a way to read cookie of *.y.com from javascriptY, which is loaded on *.x.com?

1 Answers1

0

It is not possible to read a cookie set under a different domain

Because cookies are limited by the same origin policy, which states that they are specific to the root of the HTML document they are defined in.

Cross-domain cookies: Have a look at the answer for this question, about Cross-Domain Cookies for alternative methods of sharing cookies between domains.

Alicia Sykes
  • 5,997
  • 7
  • 36
  • 64