Menu

gitpiper

isSessionStorageEnabled javascript Code Snippet in 2024

browserintermediate

Last Updated: 20 September 2024

Checks if sessionStorage is enabled.

  • Use a try...catch block to return true if all operations complete successfully, false otherwise.
  • Use Storage.setItem() and Storage.removeItem() to test storing and deleting a value in window.sessionStorage.
const isSessionStorageEnabled = () => { try { const key = `__storage__test`; window.sessionStorage.setItem(key, null); window.sessionStorage.removeItem(key); return true; } catch (e) { return false; } };
isSessionStorageEnabled(); // true, if sessionStorage is accessible

javascript snippet similar to isSessionStorageEnabled For You in September 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️