JS Storage-storage

Source: Internet
Author: User
Tags sessionstorage

Overview

In HTML5, a new localstorage feature is added, which is primarily used as a local store to solve the problem of insufficient cookie storage space (4k per cookie in the cookie). The 5M size is supported by the General browser in Localstorage.

Localstorage The advantages

1, Localstorage extended the 4K limit of cookies

2, Localstorage will be able to store the first request data directly to the local, this is equivalent to a 5M size for the front-end page of the database, compared to the cookie can save bandwidth.

Localstorage The Limitations

1. All browsers currently restrict the value type of localstorage to string type, which requires some conversion to the JSON object type that we are more familiar with everyday

2, Localstorage in the browser's privacy mode is not readable

3, Localstorage is essentially the reading of the string, if the storage of more content will consume memory space, will cause the page card

4, Localstorage can not be crawled by reptiles to

The only difference between Localstorage and Sessionstorage is that localstorage belongs to persistent storage, and sessionstorage is the key value pair in Sessionstorage is emptied when the session ends.

Api

/** JS Storage * http://www.cnblogs.com/st-leslie/p/5617130.html * http://www.cnblogs.com/yuzhongwusan/archive/2011 /12/19/2293347.html*/functionTestlocalstorage () {Debugger; Localstorage.setitem ("AAA", "AAA"); Localstorage.setitem ("BBB", "BBB"); varres = Localstorage.getitem ("AAA"); Res= localstorage["BBB"]; Res=localstorage.aaa; Localstorage.removeitem ("AAA"); Res= Localstorage.getitem ("AAA");    Localstorage.clear (); Res= Localstorage.getitem ("BBB");}functionTestsessionstorage () {Debugger; Sessionstorage.setitem ("AAA", "AAA"); Sessionstorage.setitem ("BBB", "BBB"); varres = Sessionstorage.getitem ("AAA"); Res= sessionstorage["BBB"]; Res=sessionstorage.aaa; Sessionstorage.removeitem ("AAA"); Res= Sessionstorage.getitem ("AAA");    Sessionstorage.clear (); Res= Sessionstorage.getitem ("BBB");}

Reference:

HTML5 's Sessionstorage and Localstorage

Localstorage Usage Summary

JS Storage-storage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.