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