Details about storage in web storage and webstorage

Source: Internet
Author: User

Details about storage in web storage and webstorage

Storage of web storage

I have used a lot of data storage in my recent work. I have written an article about storage blogs to help me better understand the concept. I hope you can criticize and correct it more.

I. web storage is divided into two types:, SessionStorage, localStorage;

Ii. web storage features;

1. easy configuration and reading

2. Large Capacity, sessionStorage about 5 M, localStorage about 20 M

3. Strings can be stored directly. Object Storage is stored after JSON. stringify () encoding.

4. window. sessionStorage

1) The lifecycle is to close the browser window
2) data can be shared in the same window.

5. window. localStorage

1) takes effect permanently, unless manually deleted
2) Multi-Window sharing in the same browser

Iii. Compatibility with web Storage; 


Iv. web storage string operation api (sessionStorage and localStorage operation api are the same)

Obtain local storage

window.localStorage.getItem( ‘age' )

Store a key-Value Pair locally

 window.localStorage.setItem( key,value )

Deletes a value stored locally.

window.localStorage.removeItem( key )

Clear Local Storage

window.localStorage.clear()

Obtain the key value of the Local Storage

 window.localStorage.key( index ) 

V. OSS APIs

1. Store an object locally

window.localStorage.setItem ('socketArr',JSON.stringify( { key:1 } ) );

2. obtain local storage objects

JSON.parse(localStorage.getItem ('socketArr') );

If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article. Thank you for your support!

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.