Skip to content

Example of sharing localStorage between cross-domain using iframe & postMessage

Notifications You must be signed in to change notification settings

robobakery/local-storage-share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

About this project

Example of sharing localStorage between cross-domain using iframe & postMessage.

What it does?

  • www will request token stored in localStorage of userhome.
  • userhome will respond every 10s.

Getting Started

Serve each domains

// 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

Test it!

  • 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!

About

Example of sharing localStorage between cross-domain using iframe & postMessage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages