Menu

gitpiper

isSessionStorageEnabled javascript Code Snippet in 2022

browserintermediate

Last Updated: 26 November 2022

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 November 2022

Subscribe to our Newsletter

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

© 2022 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! ✌️