title: Cannot set cookie in iframe using the Storage Access API on Safari
body: <p>I have an iframe on my page. As Safari blocks 3rd party cookies, I am trying to use the Storage Access API as suggested here under 'Developer Guidance': <a href="https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/" rel="noreferrer">https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/</a>. I have copied the following code from <a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API/Using#Accessing_a_user&#39;s_cookies_in_an_embedded_cross-origin_iframe" rel="noreferrer">the documentation</a>:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    window.addEventListener('load', () =&gt; {
      document.getElementById('test-button').addEventListener('click', () =&gt; {
        document.hasStorageAccess().then(hasAccess =&gt; {
          console.log('hasAccess: ' + hasAccess);
          if (!hasAccess) {
            return document.requestStorageAccess();
          }
        }).then(_ =&gt; {
          console.log('Now we have first-party storage access!');
          document.cookie = "foo=bar";
          console.log(`document.cookie: ${document.cookie}`);
        }).catch(_ =&gt; {
          console.log('error');
        });
      });
    });
  &lt;/script&gt;
  
  &lt;button id="test-button"&gt;Test&lt;/button&gt;
  </code></pre>
  
  <p>Browser console output:</p>
  
  <pre><code>[Log] hasAccess: true
  [Log] Now we have first-party storage access!
  [Log] document.cookie: 
  </code></pre>
  
  <p>As you can see, the grant seems to be successful but still cannot set the cookie. Does anyone have an idea what's wrong?</p>
  
  <p>Safari Version 13.0.1 </p>
  
  <p><strong>EDIT:</strong> Console output on Safari 13.1:</p>
  
  <pre><code>[Log] hasAccess: false
  [Log] error
  </code></pre>
  
  <p><strong>Note:</strong> The enclosing page is a simple <code>iframe</code> tag with a <code>src</code> pointing to this page. </p>