First, Introduction
1, in order to replace Cookile this ancient client storage technology, HTML5 's web Storage API provides two ways to store databases in the client: Localstorage and Sessionstorage
2. Sessionstorage is used to store data locally in a session, which can only be accessed by a page in the same session and destroyed when the session ends. So sessionstorage is not a persistent local store, only session-level storage.
3, Localstorage for persistent local storage, unless the data is actively deleted, the data will never expire.
4. Localstorage and sessionstorage accessed through the Window object
Ii. Methods of Use
1, SetItem storage value use:
Store value in the key field
Usage:
. SetItem (key, value)
code example:
Sessionstorage.setitem ("Key", "value");
Localstorage.setitem ("Site", "js8.in");
2, GetItem get value use:
Gets the value that is stored locally for the specified key
Usage:
. GetItem (Key)
code example:
var value = Sessionstorage.getitem ("key");
var site = localstorage.getitem ("site");
PhoneGap Storage Api_localstorage and Sessionstorage