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.