Web Storage
A Web storage stores data in the key-value format. The process is similar to existing cookies, but by using the Web Storage API, structured objects can be stored, and the storage capacity increased to 5 MB per domain. In addition, no server request is needed, so the server traffic is significantly reduced.
With the setItem() method of the Storage interface, you can store searches on certain conditions used in the browser by the user. When the user reconnects, the getItem() method is called to retrieve the stored data.
The Web Storage API provides 2 storage types:
-
Local storage
Stores data to be used in multiple windows, beyond the current session, with no expiration date. The stored data is not deleted when the browser window is closed, and can be shared between browser windows.
-
Session storage
Valid for only a single session.
The data stored in a temporary storage can be shared in all browser windows within the same domain, but once the browser window is closed, data is deleted.
If a new window is opened using a link, the session storage data is copied to the new window. However, if the data in the new window is edited, it is stored as a separate data item.