🍪 Cookies visible to JavaScript at page load:

  1. Check document.hasStorageAccess().then(status => {…}) and see that status is […]. If this returns true then cross-site cookies will be available, if false the page will need to request access.
  2. Check navigator.permissions.query({name: 'storage-access'}).then(res => {…} and see that res.state is […].
    1. If granted we can just call document.requestStorageAccess().then(res => {…}) immediately.
    2. If prompt we need to put the document.requestStorageAccess().then(res => {…}) behind a user gesture, e.g. clicking a button.

      document.requestStorageAccess().then(res => {…})[…]
  3. Subsequent requests initiated within this frame will now include cookies, so if you 🔃 navigate back here again you should see the page immediate has storage access and can see the cross-site cookie.

Notes:
💡 If you reload the entire page, you will see that storage access is not automatically granted. requestStorageAccess() must be called per frame.
💡 After a successful requestStorageAccess() call, you won't see the cross-site cookie in document.cookie immediately because the cookie was not sent with the page request.