10 examples of 'get localstorage value in php' in JavaScript

Every line of 'get localstorage value in php' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
311function getLocalStorage (currentControl, key) {
312 if (key in store) {
313 const stored = store[key];
314 if (!stored) return undefined;
315 if (currentControl.type !== stored.type) return undefined;
316 if (currentControl.value !== stored.defaultValue) return undefined;
317 // console.log('CHECK CHECK', key, currentControl.value, stored.defaultValue)
318 return stored.value;
319 }
320 return undefined;
321}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

256function getLocalData(key) {
257 if (window.localStorage) {
258 return window.localStorage.getItem(key);
259 }
260}
39function getValueFromLocalStorage() {
40 if (typeof localStorage === "undefined") {
41 return null;
42 }
43 const storedValue = localStorage.getItem(key) || "null";
44 try {
45 return JSON.parse(storedValue);
46 } catch (err) {
47 console.error(err);
48 }
49 return storedValue;
50}
163function getLocalStorageStr(key, defaultValue) {
164 return window.localStorage[key] || defaultValue;
165}
52function get(name) {
53 if (typeof (Storage) !== 'undefined') {
54 return localStorage.getItem(name)
55 } else {
56 window.alert('Please use a modern browser to properly view this template!')
57 }
58}
38function getLocalStorage(key) {
39 return localStorage.getItem(key);
40};
36export function L_getValue(key) { // 个别用户禁用本地存储会报错
37 try {
38 return localStorage.getItem(key);
39 } catch (e) {}
40}
117function getLocalStorageItem(key) {
118 try {
119 return JSON.parse(
120 window.localStorage.getItem(key)
121 );
122 } catch (e) {
123 return null;
124 }
125}
34getLocal(key: string): any {
35 const data = window.localStorage.getItem(key);
36 if (data) {
37 return JSON.parse(data);
38 } else {
39 return null;
40 }
41}
29function getLocal(key, fallback = undefined) {
30 const itemRaw = localStorage.getItem(key);
31 return itemRaw === null ? fallback : JSON.parse(itemRaw);
32}

Related snippets