WEB-210Optional
Ask before embedded content uses cookies
If embedded content needs its own cookies, ask for them with the Storage Access API. Don't rely on third-party cookies.
How to do it
In the embedded page, call document.requestStorageAccess() after a click or tap, when it needs its own cookies. Browsers only allow the call after a user action, and may show a prompt. Load the embed itself only after a click, as Load embedded videos and maps only after a click says.
Examples
JavaScript example
// Runs inside the embedded page, e.g. widget.example.com
button.addEventListener('click', async () => {
if (!(await document.hasStorageAccess())) await document.requestStorageAccess();
loadSignedInView();
});
How to check
In a browser that blocks third-party cookies, the embed shows a button first. After a click, it shows the signed-in view.
Related rules
- WEB-219 Load embedded videos and maps only after a click in Website
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/privacy/storage-access-api">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.