Every line of 'sessionstorage javascript' 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.
106 public getSessionStorage(sessionId: string) { 107 if (this.storages[sessionId]) { 108 return this.storages[sessionId] 109 } 110 const prefix = `${this.endpoint}:${sessionId}:` 111 const store = { 112 clear: () => { 113 Object.keys(localStorage) 114 .filter((key: string) => key.startsWith(prefix)) 115 .forEach(key => localStorage.removeItem(key)) 116 }, 117 getItem: (key: string) => { 118 return localStorage.getItem(prefix + key) 119 }, 120 setItem: (key: string, item: string) => { 121 return localStorage.setItem(prefix + key, item) 122 }, 123 removeItem: (key: string) => { 124 return localStorage.removeItem(prefix + key) 125 }, 126 } 127 this.storages[sessionId] = store 128 return store 129 }
145 public saveSession(session: Session, save: boolean = false) { 146 this.project.sessions[session.id] = session 147 if (save) { 148 this.saveProject() 149 } 150 }
61 onGetSession(){ this.value = sessionStorage.getItem( this.key );}
108 static getSessionData(key: string): any { 109 const sessionStorage = BrowserStorage.getSessionStorage(); 110 111 if(sessionStorage) { 112 try { 113 const item = sessionStorage.getItem(key); 114 115 if(item) { 116 return item ? JSON.parse(item) : null; 117 } 118 119 return null; 120 } catch(error) { 121 return null; 122 } 123 } else { 124 return null; 125 } 126 }
131 function showSessionStorage(){ 132 if (window.sessionStorage) { 133 s_btn_tips.innerHTML = 'sessionStorage:' + JSON.stringify(session_storage); 134 } else { 135 s_btn_tips.innerHTML = '浏览器不支持sessionStorage'; 136 } 137 }
86 public saveInLocalStorage() { 87 let session: SESSION = this; 88 window.localStorage.setItem(SESSION.const.SESSION_LOCAL_STORAGE, JSON.stringify(session)); 89 }
105 public static removeFromLocalStorage() { 106 window.localStorage.removeItem(SESSION.const.SESSION_LOCAL_STORAGE); 107 }
14 export function getSessionStorage() { 15 return (typeof window !== 'undefined') ? window.sessionStorage : null; 16 }
16 createSession(sessionId, object) { 17 this.sessions[sessionId] = object; 18 }
10 export function updateUserSessionStores(): void { 11 if (new Date().toDateString() !== lastDayActive) { 12 daysActiveCount++ 13 lastDayActive = new Date().toDateString() 14 localStorage.setItem('days-active-count', daysActiveCount.toString()) 15 localStorage.setItem('last-day-active', lastDayActive) 16 } 17 }