StorageArea.setAccessLevel()
Sets the access level for the storage area.
Sets the access level for the storage area.
Use this method to:
- Expose the `session` storage area to content scripts. Unlike other storage areas, by default, `storage.session` is only available to privileged (trusted) extension contexts by default.
- Restrict content scripts' access to `local`, `managed`, and `sync` storage areas. By default, these storage areas are exposed to all extension contexts, including content scripts.
## Syntax
```js-nolint
await browser.storage.<storageType>.setAccessLevel(
accessLevel // string
)
```
Where `<storageType>` is any of the storage types: storage.local, storage.managed, storage.session, or storage.sync.
### Parameters
- `accessLevel`
- : `String`. The access level of the storage area. Possible values are `TRUSTED_CONTEXTS` or `TRUSTED_AND_UNTRUSTED_CONTEXTS`.
### Return value
A Promise that is fulfilled with no arguments if the operation succeeded. If the operation failed, the promise is rejected with an error message.
## Browser compatibility
> [!NOTE]
> This API is based on Chromium's [`chrome.storage`](https://developer.chrome.com/docs/extensions/reference/api/storage) API. This documentation is derived from [`storage.json`](https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/storage.json) in the Chromium code.
Cite this
"StorageArea.setAccessLevel()". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/setAccessLevel JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy