HTML 5 Local Storage is based on key/value pair where key should be unique. Unlike Cookies, data is never transmitted to every page of website in case of HTML 5 Local Storage.
There are many functions available with HTML 5 Local Storage i.e. setItem(…), getItem(…), removeItem(…), clear(), key(…). In addition to it, there is a property available “length”.
The syntax for it is setItem(key,data). For example, to store username we would do as follows:
The syntax for it is getItem(key). For example, to get data of of key "username" we would do as follows:
Another way to access any item is like:
As name says, it is used to remove an item from local storage. The syntax for it is removeItem(key).
It is to delete all keys and data from local storage.
It is to retrieve key at particular index. The syntax for it is key(index).
It is to find out total number of entries in local storage.