Earlier we covered some of the new features of HTML 5, such as canvas, audio and video. In this article we'll cover many of the useful new elements that the specification brings to the table. Please remember, though, that HTML 5 is a work in progress, and not fully supported by many browsers yet.
HTML 5: What`s New - HTML 5 Web Storage (Page 3 of 3 )
The web storage API makes it easy to store data across web requests. As you all know, HTTP is stateless. In other words, the next time the same user hits a page, it is still considered a new request.
Scripting languages add their own features to remember users and their data across requests. The feature that is mostly used is a cookie. A cookie is stored on a user's computer and sent back and forth in every request to be able to determine the identity of the user and specific information about him/her. In addition, a cookie is limited in size.
Setting and getting the values of a sessionStorage is straight forward. Once the value is set, it can survive page refreshes, and can be accessed from other pages as well. But keep in mind that, since we are talking about sessions, this value will be available as long as the user's session is available (the user did not close the browser and terminate the session). The following example shows how we can set and get the session value:
localStorage is similar in use to sessionStorage, but with localStorage, values persist beyond window and browser lifetimes. You can access the data the next month, or even the next year.
This article has been an introduction to HTML 5. We touched on some of the important features, but obviously we did not cover everything (it would take a book to do so). We talked about a canvas on which to do drawings, we discussed the new elements being added, and we touched on audio and video.
It is important to note, though, that HTML 5 is not standardized yet. It is still a work in progress. Some browsers, like Firefox and Opera, support most of the features, but other browsers are still behind. It comes as no surprise that, although some of the features are neat and interesting, it is not time yet to put them to work in your web applications, unless you are definitely sure that your users use a version of the browser that supports those features.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.