Local storage in Angular 2
I need to store data in the browser's session and retrieve the data until the session exits. How do you use local and session storage in Angular 2? The standard localStorage API should be available, just do e.g.: localStorage.setItem('whatever', 'something'); It's pretty widely supported . Note that you will need to add "dom" to the "lib" array in your tsconfig.json if you don't already have it. To store data in local-storage, localStorage.setItem('key', 'value'); Make sure to stringify value, for example if you have an object localStorage.setItem(itemName, JSON.stringify(itemData)); OR for