WebStorage
The Window object implements the WindowLocalStorage and WindowSessionStorage objects which has localStorage(window.localStorage) and sessionStorage(window.sessionStorage) properties respectively. These properties create an instance of the Storage object, through which data items can be set, retrieved and removed for a specific domain and storage type (session or local). For example, you can read and write on local storage objects as below
localStorage.setItem('logo', document.getElementById('logo').value);
localStorage.getItem('logo');
What are the differences between cookie, local storage and session storage
Below are some of the differences between cookie, local storage and session storage,
Feature | Cookie | Local storage | Session storage |
---|---|---|---|
Accessed on client or server side | Both server-side & client-side | client-side only | client-side only |
Lifetime | As configured using Expires option | until deleted | until tab is closed |
SSL support | Supported | Not supported | Not supported |
Maximum data size | 4KB | 5 MB | 5MB |
Comments
Post a Comment