Session & Local Storage :
Session storage :
Session storage is a mechanism that allows you to store data temporarily for a particular session.
The data stored in session storage remains available an till the browser tab or window is open.
If the user closes the tab or window, the session storage data is cleared and no longer accessible.
Each session storage object is specific to the individual browser tab or window. Data stored in one tab is not accessible by another tab.
Session storage provides a simple key-value storage mechanism similar to JavaScript objects.
You can access session storage using the sessionStorage object in JavaScript.
Local Storage:
Local storage is similar to session storage but provides persistent(Constant) storage that available even after closing the browser or restarting the computer.
The data stored in local storage will be there until removed by the web application or cleared by the user
Local Storage More :
Unlike session storage, local storage is not limited to a specific session or tab. Data stored in local storage is accessible across multiple tabs and browser sessions.
Local storage is useful for applications that require long-term data storage, such as user preferences, cached data, or offline data.
Like session storage, local storage also uses a key-value pair storage mechanism and can be accessed using the localStorage object in JavaScript.
Both Session and Local :
Both session storage and local storage have a size limit, typically several megabytes depending on the browser.
They support storing data as strings, so if you want to store complex data structures like objects or arrays, you need to serialize and deserialize them using JSON.stringify() and JSON.parse().
To summarize, session storage provides temporary storage for a specific session or browser tab, while local storage offers persistent storage accessible across multiple sessions and tabs.
Both options are useful for web applications to store data on the client-side.