25 lines
649 B
JavaScript
25 lines
649 B
JavaScript
|
// Function to get data from localStorage
|
||
|
function getLocalStorageItem(item) {
|
||
|
// When cookies are disabled
|
||
|
if (!cookiesEnabled) return "";
|
||
|
// Try to get data from localStorage
|
||
|
try {
|
||
|
return localStorage.getItem(item);
|
||
|
// Failed to access localStorage
|
||
|
} catch {
|
||
|
// Return empty result
|
||
|
return "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Function to set data to local storage
|
||
|
function setLocalStorageItem(item, value) {
|
||
|
// When cookies are disabled
|
||
|
if (!cookiesEnabled) return;
|
||
|
// Try to save data to localStorage
|
||
|
try {
|
||
|
localStorage.setItem(item, value)
|
||
|
// Failed to access localStorage
|
||
|
} catch {}
|
||
|
}
|