Skip to content

Instantly share code, notes, and snippets.

@jscodelover
Created October 5, 2020 10:33
Show Gist options
  • Save jscodelover/93f9410eae5ea710d0c4c9da5d1bcc22 to your computer and use it in GitHub Desktop.
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 )
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