It is an alternative to cookies and it is better than cookies. With the help of localstorage we can store data locally inside user browser. It is more secure as compared to cookies. It can be modified easily using setItem() and getItem() method.
It store user data with no expiration date means user data will persist even when browser has been closed.
It is similar to localstorage except that it stores the data for only one session. The data gets deleted once user closes the specific browser tab.