local-storage


How to mock localStorage in JavaScript unit tests?

Here is a simple way to mock it with Jasmine: beforeEach(function () { var store = {}; spyOn(localStorage, 'getItem').andCallFake(function (key) { return store[key]; }); spyOn(localStora... Read More


javascript - Local storage vs AngularJS $cacheFactory

If your goal is to store client-side and persistent data, you can't use the $cacheFactory, which just caches the data for the current session. One solution is to use the new local storage API. This a... Read More


javascript - Scope of sessionStorage and localStorage

Session Storage: Values persist only as long as the window or tab in which they stored. Values are only visible within the window or tab that created them. Local Storage: Values persist window and... Read More


security - Should JWT be stored in localStorage or cookie?

I like the XSRF Double Submit Cookies method which mentioned in the article that @pkid169 said, but there is one thing that article doesn't tell you. You are still not protected against XSS because w... Read More


html - Viewing local storage contents on IE

Since localStorage is a global object, you can add a watch in the dev tools. Just enter the dev tools, goto "watch", click on "Click to add..." and type in "localStorage".... Read More


html - HTML5 Pre-resize images before uploading

Yes, use the File API, then you can process the images with the canvas element. This Mozilla Hacks blog post walks you through most of the process. For reference here's the assembled source code from... Read More


How do I view the storage of a Chrome Extension I've installed?

There is a very helpful extension to work with both localStorage and chrome.storage that I recently discovered, that works as a Dev Tools panel. Storage Area Explorer I did not write this, but it wa... Read More


angularjs - localStorage vs sessionStorage vs cookies

localStorage and sessionStorage are both so-called WebStorages and features of HTML5. localStorage stores information as long as the user does not delete them. sessionStorage stores information as lo... Read More


local storage - Is it safe to store a jwt in localStorage with reactjs?

In most of the modern single page applications, we indeed have to store the token somewhere on the client side (most common use case - to keep the user logged in after a page refresh). There are a to... Read More


local storage - Clearing localStorage in javascript?

Use this to clear localStorage: localStorage.clear();... Read More