HTML 5 is the latest buzz in developing RIA (Rich Internet Application). One the best features in HTML 5 is Web Storage!
It's really amazing and powerful. It totally replaces the traditional Cookies!
HTML 5 Web Storage is of two types -
1. Local Storage
2. Session Storage
I discussed Local Storage on my blog (see below) but will discuss Session Storage in detail here, so that you can kick start using it at once, when you are done reading this article.
In contrast to Local Storage, the lifetime of this storage is per session. When the user closes the browser, the stored data expires. It just stores data for particular session.
Similar to Session in Server Side Programming( ASP.NET, PHP ), it just holds the data in Client Side.
Unlike Cookies, it won't travel with each request to the server. It will be available in the browser and it can be retrieved when it requires.
Storing and retrieving data in the Session Storage is pretty simple!
Store data in Session Storage!
<script type="text/javascript">//Check whether the browser supports Session Storage, if yes, then store the data.if (window.sessionStorage) { sessionStorage.myName = "Session Storage"; }</script>
Data is stored as Key/Value pair! So in the above code -
myName is Key, Session Storage is Value.
It's always a good practice, to check whether the feature is supported by the browsers or not, since the feature may not be support in the older browsers! In that case you have a chance to create a fall back method.
Hi, is it also worth mentioning that If you are developing web apps that utilise localStorage on mobile Safari that Apple have made a change that make it non- persistent from iOS5.1 onward.. Doh!
Comments (6)
Author
Commented:Thanks for the feedback! I'll try to update the article pretty soon!
Commented:
http://www.moneytoolkit.com/2012/04/apple-ios-html5-localstorage-is-broken/
Author
Commented:Thanks for the update!
Author
Commented:I'm done updating the information suggested by the users!
Commented:
View More