HTML5 Local Storage vs Session Storage

Some new features in HTML5 are really useful, like Web Storage, but you have to make sure you understand how it works and make sure you use it in the correct scenarios. There are actually two ways that HTML 5 Web Storage works: local and session storage. I ended causing some end-user confusion by using local storage all the time, so here is breakdown of how both work and when they should be used.

Local Storage
When using window.localStorage, the data associated to this object will never expire. So long as you don't uninstall your browser (or forcefully delete the data), the data held within this object will remain forever.

So a good example of using localStorage is when you have a web application where you create data and want to remember the last country selected, so the user doesn't always have to re-select it. So write your JavaScript code to remember the last country used and then retrieve it the next time the user comes to the page to preset the last selected country.

Session Storage
When using window.sessionStorage, this data will only be retained for a browser session. Meaning that once the user closes the browser instance, the data is gone.

This is useful when you have a search page and want to always retain and show the last criteria entered by the user. But once the user closes the browser, you want the data to be gone, so when he or she re-enters your application the next time, they start with a fresh page.


Anonymous said...

Does your site have a contact page? I'm having problems locating it but, I'd like to send you an e-mail.

I've got some recommendations for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.

Also visit my blog post ... toddler hitting

Anonymous said...

Latest trimonthly [url=http://hermes.ruren.org/][b]エルメス 店舗[/b][/url]
results, fitted at dependable pursuit rates, Hermes takings increased aside [url=http://hermes.ruren.org/]エルメス 財布[/url]
12.8% to 856.8 million euros, compared with 776.9 million euros in the same duration in 2012, an extend of more than 11% of [url=http://hermes.ruren.org/][b]エルメス 店舗[/b][/url]
the chap base participants ahead to, but compared with sales in the prime district of 2012, an developing of [url=http://hermes.ruren.org/]hermes エルメス[/url]
17.6%words, has slowed; at contemporaneous buying rates, Hermes in the prime phase of the moon [url=http://hermes.ruren.org/][b]エルメス 財布[/b][/url]
proceeds progress of 10.3%, during the constantly of recompense scold fluctuations set someone go the comrades 19 million euros. [url=http://hermes.ruren.org/]エルメス バッグ[/url]
In counting up, the retinue's retail ???[url=http://hermes.ruren.org/][b]エルメス 財布[/b][/url]
approach sales proliferation of 13.6%, the wholesale conduit sales multiply of 9.9%.