Storage Access API
The Storage Access API lets a cross-site iframe ask for its unpartitioned cookies. These are the cookies the site has when the user opens it in a top-level tab.
Browser API
Also called requestStorageAccess
Updated
On this page
Example
JavaScript in the iframe
button.addEventListener("click", async () => {
if (await document.hasStorageAccess()) return;
await document.requestStorageAccess();
location.reload();
});The request must come from a click or a tap. After the grant, reload the frame so the requests send the cookies.
How to use it
Call requestStorageAccess() from a click in the frame. If the frame has a sandbox, the parent must add three tokens.
async function askForCookies() {
if (await document.hasStorageAccess()) return true;
try {
await document.requestStorageAccess();
location.reload();
return true;
} catch {
return false; // denied: open the site in a new tab
}
}Cookies still need SameSite=None and Secure. Chrome treats a cookie with no SameSite as Lax.
Learn more
Sources