Skip to content

shenfe/xcookie.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xcookie.js

Get cross-domain cookies in "iframe" way.

Usage

  1. 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']
  2. Place the xcookie.html page file somewhere under the target domain (e.g. "www.target.com") whose cookie you would like to get.

  3. 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));
        }
    });

Compatibility

IE7+.

Thanks

License

MIT

Copyright © 2017-present, shenfe

Releases

No releases published

Packages

No packages published