HTML5 Web Storage Tutorial is a better local storage as compare to cookies. The web storage is supported by all the browser.
Generally there are two storage used in HTML5, these are-
Generally there are two storage used in HTML5, these are-
- Session Storage
- Local Storage
Session Storage:
The Session Storage is intended for situations wherever the user is carrying out a single transaction, however may be carrying out multiple transactions in numerous windows at the similar time. The session storage is equal to the local storage, leaving that it stores the data for only one session. The data ought to be deleted when the user closes the browser window.Example:
| <html> <head> <script> if( sessionStorage.catch ){ sessionStorage.catch = Number(sessionStorage.catch) +1; } else { sessionStorage.catch = 1; } document.write(“Total catch :” + sessionStorage.catch ); </script> </head> <body> <p>Refresh if you want to increase number of catches in the page.</p> <p>Close the browser and try again.</p> </body> </html> |
Local Storage:
The Local HTML5 Tutorial Web Storage is intented for storage that spans multiple windows, and lasts beyond the current session.The local storage stores the information with no expiration date. The information will not be deleted once the browser is closed and can be out there on the next day.Example:
| <html> <head> <script> if( localStorage.catch ){ localStorage.catch = Number(localStorage.catch) +1; } else { localStorage.catch = 1; } document.write(“Total catch :” + localStorage.catch ); </script> </head> <body> <p>Refresh if you want to increase number of catches in the page.</p> <p>Close the browser and try again.</p> </body> </html> |
No comments:
Post a Comment