🍪 Cookies visible to JavaScript at page load:
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.navigator.permissions.query({name: 'storage-access'}).then(res => {…}
and see that res.state
is […]
.granted
we can just call document.requestStorageAccess().then(res => {…})
immediately.prompt
we need to put the document.requestStorageAccess().then(res => {…})
behind a user gesture, e.g. clicking a button.
document.requestStorageAccess().then(res => {…})
→ […]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.