Posts

Showing posts from May, 2014

HTML5 | LocalStorage

HTML5 LocalStorage a feature that's been added to HTML5 specification, which enables storing data on clients machine, which can be retrieved and manipulated for future use unless the user clears the cache from browsers. Though we can store data there is a limitation as in how much we can store, the current max size of storing is 5Mb, which is quite a big amount, lets look how to store  and retrieve data on client's machine Storing data: To store data we use the native localStorage.setItem(key,value) method which expects two arguments as shown the key and the value like so: localStorage.setItem('user_name','purush'); Retrieving Data: To Retrieve data we use the native localStorage.getItem(key) method which expects one argument as shown which is the key, lets retrieve the previously stored data localStorage.getItem('user_name'); this will return 'purush' Clearing Data: To remove or clear stored data we can use either localStorage.rem