Add function `Cookies.enabled(): bool` that returns if cookie access is enabled
Author: cdriniCreated May 10, 2023Updated Jan 6, 2026
Labelsfeature request
Is your feature request related to a problem? Please describe.
Cookies are disabled when a page is in a sandboxed iframe. In this case, trying to access document.cookie throws an error:
SecurityError: Document.cookie getter: Forbidden in a sandboxed document without the 'allow-same-origin' flag.
Describe the solution you'd like It would be helpful to have a function from the Cookies library to check.
Describe alternatives you've considered I've implemented my own:
function cookies_enabled() {
try {
// In security locked iframes, document.cookie throws an error.
document.cookie;
return true;
} catch (e) {
return false;
}
}Additional context Add any other context or screenshots about the feature request here.
Source: js-cookie/js-cookie