2018-08-04 Preface this question when doing the project today, how to change the login link to the user name after the user login is successful
Solution: OnLoad Load event with Sessionstorage cache and JS
After the user has successfully logged in, use the cache, set the user name to the cache, and then get it when each page loads.
The difference between Localstorage and sessionstoragecommon: All are stored in the browser side, and the same Origindifference:
: 1, Sessionstorage and localstorage do not automatically send data to the server, only locally saved. ’
2, Sessionstorage and Localstorage although there is a storage size limit, but much larger than the cookie, can reach 5M or greater
3. Data validity is different, Sessionstorage: only valid until the current browser window is closed; localstorage: Always valid, window or browser Close is also saved, so it is used as persistent data;
4, the scope is different, sessionstorage is not shared in different browser windows, even the same page; localstorage are shared across all homologous windows;
5, the Web Storage support event notification mechanism, you can send the notification of data updates to the listener
6, the Web Storage API interface to use more convenient. Reference Links:
the difference between a Cookie, a session and a localstorage, and a sessionstorage
2.javascript The difference between the cache localstorage and Sessionstorage