localstorage on iOS Safari does not persist in iFrames

I'm currently working on a web application which sits inside an iframe for security purposes (protecting user data) and is hosted on other websites. To keep session state for insecure data, we write some data to local storage for user functionality i.e., remembering the user's background colour we save "backgroundColour" as "red".


However I have run into the following two issues on iOS Safari which currently work on MacOS Safari and Chrome and internet Explorer 11.


---


Issue 1: local storage is not retained when I force quit iOS:

  1. The user navigates to the host website,
    www.host.com
    , which loads my iframe content from a different domain,
    www.example.com
  2. The user then interacts with the iframe and saves their background colour preferences which I save to local storage.
  3. The user then force quits Safari or navigates away and then force quits Safari.
  4. Navigate back to the host website


Expected behaviour: The localStorage contains the backgroundColour property

Actual behaviour: The local storage is empty


---


Issue 2: using the iframe content on different sites doesn't utilise local storage


  1. The user navigates to the host website,
    www.host.com
    , which loads my iframe content from a different domain,
    www.example.com
  2. The user then interacts with the iframe and saves their background colour preferences which I save to local storage.
  3. The user navigates to www.awesomesite.com which also has my iframe content from the domain in step 1,
    www.example.com


Expected behaviour: The local storage is retained between the different sites because the storage is against DNS of the iframe

Actual behaviour: The local storage is empty


---


Note: we are not looking at using Cookies.


Has anyone experienced this before? Are there any workarounds that people have found? Is this a bug in iOS Safari? Have I done something wrong?


Cheers

Replies

I've been seeing this exact same behaviour, not sure how to solve it as this is causing a workflow issue with our project. Did you find any solution to this?

  • Hey ! Did you find a solution to this problem

Add a Comment