I am setting a cookie from a local HTML file as shown below using the cookie.js library
$.cookies.set("Demo","Dummy Data");
From another domain, I am trying to get a cookie using the code below
alert($.cookies.get("Demo"));
But he returns me zero.Please help me on this.
This is by design. You can only get the cookie value that was set in the current domain.
What you ask for is not possible due to security measures built into web browsers.
The best alternative is to make a JSONP AJAX request that can cross domains.
cookie, .
: cookie
, . domain.com , domain1.com , -.
, null, cookie . .
, , cookie -. cookie JS , - ( ) . , . , , , , , blackhat, - voila - , -. , , - ... . !
- , !
, - SOP ( ).
, postMessage, JSONP, xmlHttpRequest iframe, .
. . .