Created
September 19, 2021 17:08
-
-
Save ats1999/877f00d4618f091e606bd77fd0a58f8c to your computer and use it in GitHub Desktop.
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
// get item from local storage | |
export const getLocalStorage = (str)=>{ | |
try { | |
return localStorage.getItem(str); | |
} catch (error) { | |
// cookie is blocked | |
return false; | |
} | |
} | |
// set item into localstorage | |
export const setLocalStorage = (str,val)=>{ | |
try { | |
localStorage.setItem(str,val); | |
return true; | |
} catch (error) { | |
// cookie is blocked | |
return false; | |
} | |
} | |
// check if cookie is enabled | |
export const isCookie=()=>{ | |
try { | |
return Boolean(localStorage); | |
} catch (error) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment