Web storage in html5:

Source: Internet
Author: User
Tags sessionstorage

The data carried by the browser (client) when accessing the server is stored in the cookie, but the size of data stored in the cookie is limited.

Html5 web storage is divided:

LocalStorage storage:

<Script>
If (window. localStorage ){
LocalStorage. name = 'admin ';
LocalStorage ['age'] = '23 ';
LocalStorage. setItem ('gender', 'male ');
// LocalStorage. removeItem ('name ');
// LocalStorage. clear ();;
} Else {
Alert ('no ');
}
</Script>

SessionStorage storage:

<Script>
If (window. sessionStorage ){
SessionStorage. name = 'admin ';
SessionStorage ['age'] = '23 ';
SessionStorage. setItem ('gender', 'male ');
} Else {
Alert ('no ');
}
</Script>

Their difference is that localStorage is stored on the client, with no size limit and no time limit.

SessionStorage: in the currently accessed page, once the page is closed, the variable will be released next time you access the page.

The only difference is that sessionStorage stores the currently accessed page.

 

 

Related Article

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.