PhoneGap Storage Api_localstorage and Sessionstorage

Source: Internet
Author: User
Tags sessionstorage

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

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.