MDN self-hosted library · e01.org

Using the Storage Access API

Storage Access API

Storage Access API

The Storage Access API can be used by embedded cross-site documents to verify whether they have access to third-party cookies and unpartitioned state and, if not, to request access. We'll briefly look at a common storage access scenario.

[!NOTE] When we talk about third-party cookies in the content of the Storage Access API, we implicitly mean unpartitioned third-party cookies.

Usage notes

The Storage Access API is designed to allow embedded content to request access to third-party cookies and unpartitioned state — most modern browsers block such access by default to protect user privacy. Since embedded content won't know what a browser's behavior is going to be in this regard, it's best to always check whether the embedded iframe has storage access before attempting to read or write a cookie. This is particularly true for Document.cookie access, as browsers will often return an empty cookie jar when third-party cookie access is blocked.

In the example below, we show how an embedded cross-site iframe can access third-party cookies and unpartitioned state under a browser storage access policy that would otherwise block access to them.

Allowing a sandboxed \