Search code examples
javascripthtmlstoragesession-storage

Is there a wrapper for HTML5 sessionStorage that provides a good compatability implementation?


We would like to use the HTML5 sessionStorage (or something like it) in a new project but you can't rely on it on some browsers. There's this project (http://code.google.com/p/sessionstorage/) which provides an implementation that works a lot of places, yet oddly it doesn't use the HTML5 version if it is available. It always does its own thing.

There's this project (https://github.com/jas-/jQuery.handleStorage) over on GitHub but its emulation layer is cookies (bleh!).

Note: The above is incorrect, see the answer from jas- below where he explains that I was mistaken about that project.

Is there anything better out there that offers a good implementation like the first project but falls back automatically to HTML5 if it is available? We might retrofit the first project to automatically fall back to HTML5 if available but would rather not build that if there's already a good solution out there.


Solution

  • I ended up doing more research on this because I liked both of the answers I got, but I wanted something more like the YUI 3: Storage Lite but that didn't require YUI. Something that was framework agnostic or jQuery friendly would work a lot better for us.

    In the end I found a couple of possibilities and one stood out as what we'll try and put to use: Lawnchair

    Also considered: store.js, AmplifyJS