SessionStorage, localStorage, and cookies are all data stored on the browser side, with sessionStorage being a special concept that introduces the concept of a "browser window". SessionStorage is the data that always exists in the same window (or tab) of the same source. That is to say, as long as the browser window is not closed, even if you refresh the page or go to another page in the same source, the data still exists. When the window is closed, sessionStorage is destroyed. Different windows that are opened "independently", even on the same page, have different sessionStorage objects.
Benefits of Web Storage: Reduced network traffic: Once data is saved locally, it can be avoided by requesting data from the server again, thus reducing unnecessary data requests and unnecessary back-and-forth between the browser and the server. Display data quickly: good performance, reading data from local is much faster than getting data from the server over the network, local data can be instantly available. Plus the page itself can be cached, so the entire page and data can be displayed immediately if it is local. Temporary storage: Many times data is only needed for the duration of a set of pages that the user is viewing, and the data can be discarded when the window is closed, in which case using sessionStorage is very convenient.
The difference between browser-local storage and server-side storage is that data can be stored both locally in the browser and server-side.
Browser-side data can be saved and directly retrieved locally when needed. sessionStorage, localStorage, and cookies are all stored locally by the browser.
The server side can also save all the data of all the users, but the browser has to request the data from the server when needed.1. The server side can save the user's persistent data, such as databases and cloud storage save a lot of the user's data on the server side.2. The server side can also save the user's temporary session data. The server-side session mechanism, such as the session object of jsp, saves the data on the server. To realize this, the server and the browser only need to pass the session id between them, and the server finds the corresponding user's session object according to the session id. The session data is only valid for a certain period of time, which is the session validity period set on the server side.
The server side saves all the users' data, so the server-side overhead is larger, while the browser-side saving distributes the data needed by different users in the users' respective browsers. Browser side is generally used to store only small data while server can store big or small data. Servers are safer for storing data and browsers are only suitable for storing general data.