In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the difference between sessionstorage and localstorage. I hope you will gain a lot after reading this article. Let's discuss it together.
Difference: the localStorage life cycle is permanent, and unless the user clears the localStorage information, it will last forever; the sessionStorage life cycle is the current window or tab, and once the window or tab is permanently closed, all data stored through it is cleared.
LocalStorage, like sessionStorage, is an object used to store temporary information on the client.
All of them can only store objects of string type (although objects of other native types can be stored in the specification, so far no browser has implemented them).
The localStorage life cycle is permanent, which means that unless the user appears to clear the localStorage information on the UI provided by the browser, the information will last forever.
The sessionStorage life cycle is the current window or tab, and once the window or tab is permanently closed, all data stored through sessionStorage is cleared.
Different browsers cannot share information in localStorage or sessionStorage. Different pages in the same browser can share the same localStorage (pages belong to the same domain name and port), but different pages or label pages cannot share sessionStorage information. It is important to note that pages and tags only refer to top-level windows, and if a tab contains multiple iframe tags and they belong to the same origin page, then sessionStorage can be shared between them.
The rule of judgment of homology:
Comparison of URL "http://www.example.com/dir/page.html".
Compared with URL results, http://www.example.com/dir/page2.html homologous protocol, host, port http://www.example.com/dir2/other.html same protocol, host, port http://username:password@www.example.com/dir2/other.html homologous protocol, host, port http://www.example.com:81/dir/other.html different origin same protocol, host Different https://www.example.com/dir/other.html, different source protocol, different http://en.example.com/dir/other.html, different source, different host, different http://example.com/dir/other.html, different origin, different host (exact match is required) http://v2.www.example.com/dir/other.html, different origin, different host (exact match is required) http://www.example.com:80/ Dir/other.html depending on the situation, the port is clear. Dependent on browser implementation
Unlike other browsers, IE does not include ports when calculating sources.
The parse and stringify provided by the JSON object convert other data types into strings and store them in storage.
Mode of operation:
Save:
Var obj = {"name": "xiaoming", "age": "16"} localStorage.setItem ("userInfo", JSON.stringify (obj))
Fetch:
Var user = JSON.parse (localStorage.getItem ("userInfo"))
Delete:
LocalStorage.remove ("userInfo)
Clear:
LocalStorage.clear (); after reading this article, I believe you have a certain understanding of the difference between sessionstorage and localstorage, want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.