When will sessionStorage and localStorage be used respectively?

when will sessionStorage and localStorage be used respectively? Do you see that localStorage, is used more often? do they have their own usage scenarios? Or do you like it all by yourself?

Dec.14,2021

when to use is based on their respective functions and requirements.
localStorage can be stored for a long time, as long as you do not clean up the data will exist for a long time, for example, the background menu loaded with ajax can be stored at login
sessionStorage life cycle is the current window or tab, once the window or tab is permanently closed, then all data stored through sessionStorage will be emptied.
and different pages in the same browser can share the same localStorage, but different pages or tabbed pages cannot share sessionStorage information (if a tab contains multiple iframe tags and they belong to the same origin page, then they can share sessionStorage)

Menu