Storage access
The hasStorageAccess() method of the Document interface returns a Promise that resolves with a boolean value indicating whether the document has access to third-party, unpartitioned cookies.
This method is part of the Storage Access API.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 119 | 85 | 65 | 11.1 | 120 | 11.3 | |
| HTML attribute | ||||||
allow (storage-access) Experimental | 113 | 113 | | | 113 | |
| DOM API | ||||||
| The requestStorageAccess() method of the Document interface allows content loaded in a third-party context (i.e., embedded in an iframe) to request access to third-party cookies and unpartitioned state. This is relevant to user agents that, by default, block access to third-party, unpartitioned cookies to improve privacy (e.g., to prevent tracking), and is… | 119 | 85 | 65 | 11.1 | 120 | 11.3 |
permission_storage-access `storage-access` permission | 119 | 85 | 117 | 26.2 | 120 | 26.2 |
| Other | ||||||
storage-access Experimental The HTTP Permissions-Policy header storage-access directive controls whether a document loaded in a third-party context (i.e., embedded in an iframe) is allowed to use the Storage Access API to request access to unpartitioned cookies. | 113 | 113 | | | 113 | |
- Client-side storage access is granted per-page (see explanation).
- Client-side storage access is granted per-page (see explanation).
Syntax
document.hasStorageAccess().then((hasAccess) => {
if (hasAccess) {
// storage access has been granted already.
console.log("cookie access granted");
} else {
// storage access hasn't been granted already;
// you may want to call requestStorageAccess().
console.log("cookie access denied");
}
}); Use cases
-
Using Storage access
The hasStorageAccess() method of the Document interface returns a Promise that resolves with a boolean value indicating whether the document has access to third-party, unpartitioned cookies.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.