Example of sharing localStorage between cross-domain using iframe & postMessage.
- www will request token stored in localStorage of userhome.
- userhome will respond every 10s.
// open a new tab to run userhome.
$ cd userhome
$ python -m SimpleHTTPServer 8000
// open another tab to run www.
$ cd www
$ python -m SimpleHTTPServer 8001
- connect to userhome:
http://localhost:8000
- in console, type `localStorage.setItem('token', [ANY_VALUE_YOU_WANT]);
- then, connect to www:
http://localhost:8001
- and you will see tokens transferred from userhome
- any changes made to userhome will be detected.
- done!