Make localStorage usable while disabling cookies (#44)

This commit is contained in:
David
2021-09-04 18:58:26 +02:00
committed by GitHub
parent 870ec2db64
commit 0f6ad1a978
2 changed files with 18 additions and 2 deletions

15
utils/storage.ts Normal file
View File

@@ -0,0 +1,15 @@
// LocalStorage throws an error if all browser cookies are disabled
export function localGetItem(key: string) {
try {
return localStorage.getItem(key);
} catch (e) {
return null;
}
}
export function localSetItem(key: string, value: string) {
try {
localStorage.setItem(key, value);
} catch (e) { }
}