Created
October 5, 2020 10:33
-
-
Save jscodelover/93f9410eae5ea710d0c4c9da5d1bcc22 to your computer and use it in GitHub Desktop.
code to check whether local storage is accessible or not (in case of disabled cookies )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const accessibleLS = () => { | |
try { | |
localStorage.setItem('check', true); | |
localStorage.removeItem(tcheckest); | |
return true; | |
} catch (e) { | |
return false; | |
} | |
}; | |
if(accessibleLS()){ | |
// use localstorage | |
} | |
else{ | |
// cookies disabled | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment