Local Browser Storage Example

Local Browser Storage Example

HTML5 adds a new feature that can be very handy in certain circumstances.  Local Storage lets us to store data (in key / value pairs) on the clients machine via the browser.   It soes this with a new JavaScript API.  Its better than cookies because:

  • It can store more data
  • The data isn’t cleared when all cookies are deleted
    • Only when data from that specific website is deleted in the browsers setting or via a plugin.
  • No expiration date on the data

It has two draw backs:

  • Some people don’t allow any websites to store local data.
  • It can’t be encrypted easily so it’s not a safe place to store session tokens, login info or anything else of a sensitive nature.
    • Because of this, some people think it shouldn’t be used at all, ever.  I can think of usage scenarios that don’t need the information encrypted though.

Here’s an example of it’s usage:

Example

3 Comments

  1. Put me in the camp that says to never store anything this way at all.

  2. Dude! You could exactly use this for online browser based games. Not the user name , but info on the users character, level progress etc.

  3. I’d really like to learn how to do this. Can you show me?

Leave a Reply to CindyW Cancel reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)