StorageAccessHandle: thuộc tính sessionStorage

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Thuộc tính sessionStorage của giao diện StorageAccessHandle trả về một đối tượng Storage phiên không phân vùng nếu quyền truy cập được cấp, và ném ra SecurityError DOMException trong trường hợp khác.

Giá trị

Một đối tượng Storage.

Ví dụ

js
document.requestStorageAccess({ sessionStorage: true }).then(
  (handle) => {
    console.log("sessionStorage access granted");
    handle.sessionStorage.setItem("foo", "bar");
  },
  () => {
    console.log("sessionStorage access denied");
  },
);

Note: Xem Using the Storage Access API để biết ví dụ đầy đủ hơn.

Thông số kỹ thuật

Thông số kỹ thuật
Extending Storage Access API (SAA) to non-cookie storage
# dom-storageaccesshandle-sessionstorage

Tương thích trình duyệt

Xem thêm