EDITED description:
I have example.com
which hosts an iframe to app.example.com/signup
. Whenever app.example.com/signup
loads, I want to set a localStorage item for app.example.com
from within the iframe:
---------------------------------------
| example.com |
| |
| ___________________________ |
| | app.example.com/signup | |
| | (iframe) | |
| | | |
| | 'coupon': 'discount30' | |
| |_________________________| |
|_____________________________________|
example.com
code:
<iframe src="https://app.example.com/signup"></iframe>
app.example.com/signup
code:
<script>
localStorage.setItem('coupon', 'discount30');
</script>
// Signup form
Then when I go to app.example.com
(not /signup
), I want to be able to access the storageItem I created previously from within the iframe
---------------------------------------
| app.example.com |
| |
| 'coupon' localStorage does not exist|
|_____________________________________|
but it looks like it's not persisted (or I can't access it); Although the iframe app.example.com/signup
and app.example.com
share the same domain.
The most closely related issue I encountered was this one: Iframe localStorage on Safari and Safari mobile