Get cross-domain cookies in "iframe" way.
-
Define the invoker-hostname whitelist and the cookie-name whitelist in
dist/xcookie.html
. For example:Define the invoker-hostname whitelist:
Replace
[/* Define a whitelist of host names here. */]
with
['.invoker.com']
Define the cookie-name whitelist:
Replace
[/* Define a whitelist of cookie names here. */]
with
['name1', 'name2']
-
Place the
xcookie.html
page file somewhere under the target domain (e.g. "www.target.com") whose cookie you would like to get. -
Import the
dist/xcookie.js
script file in your page, and use it like this:iframexcookie({ src: 'http://www.target.com/path/to/xcookie.html', cookieNames: ['name1'], doneWith: function (data) { alert(JSON.stringify(data)); } });
IE7+.
Copyright © 2017-present, shenfe