HTML5 Web storage
HTML5 web storage, better than a cookie local storage.
What is HTML5 Web storage?
Use HTML5 can browse the data stored locally on the user.
Earlier, local storage using cookies. But Web security and storage needs more quickly. These data will not be stored on the server, but the data only for the data requested by the user on the site. It can also store large amounts of data without affecting the performance of the site.
Data as key / value pairs exist, web page data is only allowed to use the web access.
Internet Explorer 8+, Firefox, Opera, Chrome, and Safari support Web Store.
Note: Internet Explorer 7 and earlier versions of IE do not support web store.
localStorage and sessionStorage
Two objects stored in the client data is:
- localStorage - no time limit data storage
- sessionStorage - Data Storage for a session of
Before using web storage, check browser support and localStorage sessionStorage:
No time limit data storage localStorage object. The next day, after the second week, or next year, the data is still available.
- Use key = "lastname" and value = "Smith" Create a localStorage key / value pairs
- Retrieval key for the "lastname" value and then inserts id = "result" element in
Tip: Key / value pairs are usually stored as a string, you can according to their need to convert the format.
The following example shows the number of times a user clicks on a button to convert the string value to a digital code type:
sessionStorage method for a session for data storage. When the user closes the browser window, the data will be deleted.
How to create and access a sessionStorage ::