Safari uses sessionStorage instead of localStorage
<p>I'm executing the following Javascript in an <strong><em>iframe</em></strong> in the Safari 9.1 and 9.1.1 browser:</p>

<pre><code>...
&lt;script&gt;
    window.onmessage = function(e) {
        window.localStorage.setItem('myitem', 'myvalue');
    }
&lt;/script&gt;
...
</code></pre>

<p>According to the Safari developers tools Storage view the entry gets successfully set without errors.
The problem is that it is getting set in the "Session Storage" instead of "Local Storage" where I want the entry to be set.</p>

<p>In Chrome and IE11 and higher the above line sets entry in the "Local Storage" as I expect.</p>

<p>How can I store my entry in the Safari's "Local Storage" ?</p>

<p><strong>Update</strong></p>

<p>The behaviour depends on the browser security setting:</p>

<pre><code>Preferences -&gt; Privacy -&gt; Cookies and website data
</code></pre>

<p>If it is set to <code>Allow from websites I visit</code> (default) then the initial line stored value in the Session Storage.
If it is set to <code>Always allow</code> then the value gets stored in the Local Storage.</p>

<p>Is there a way to write into Local Storage from an iframe even with default <code>Allow from websites I visit</code> setting set?</p>