2

My application uses client side database storage using webSQL to store information for the user. I have heard that browsers are starting to turn away from webSQL. Currently only chrome, safari and Opera support it. Because IE and Firefox don't support webSQL I am using cookies to store information if the user is using those browsers. However cookies are not very secure and it is difficult to store large amounts of data. My question is then, is there any better option right now similar to the javascript API that all browsers support? Thanks.

1
  • 1
    If you're looking for something truly cross-browser, you're out of luck for the time being (until HTML5 is official anyway). LocalStorage should eventually do the job, but simulating an RDBMS in the browser might be a little overkill. Storing anything client-side is inherently insecure, as it's in the control of the client. Commented Jul 24, 2012 at 16:22

2 Answers 2

4

I think IndexedDB would be an option for you which is an Object based data store. It is currently supported by Chrome, Firefox and IE 10 will also support it in future.

Have a look at the following presentation to get a better understanding http://html5-demos.appspot.com/static/html5storage/index.html#slide1

From my experience I would suggest to use a wrapper library just to reduce the risk in future changes in browsers. Few popular libraries are given below

  1. Storage polyfill By Remy Sharp
  2. Amplify.js By appendTo HTML5 API with fallbacks for HTML4 browsers (including IE6)
  3. RealStorage HTML5 API is a subset of overall API
  4. YUI3 CacheOffline by YUI team
  5. Persistence.js Asynchronous Javascript object-database mapper
  6. YDN-DB Easy to use database wrapper for IndexedDB, WebSql and localStorage build on top of closure library.
Sign up to request clarification or add additional context in comments.

Comments

2

I'm a couple of years late, but given the developments in the client-side browser space since this question was asked, I thought I'd add in my two cents.

At the time this question was asked, IndexedDB was the only alternative WebSQL, though support for it was spotty at the time. Though today the former still holds true, the latter does not: now, all of the major browser vendors have an implementation of IndexedDB.

Considering IndexedDB is the only database that remains on the W3C standards track at this point, it is pretty much the only option as far as native client-side databases go.

But before you dive in to IndexedDB, there are a couple of things you should know about it. The first is that it is a non-relational document store, and as such does not natively support SQL. The second is that its API is... unwieldy to say the least.

Given these things, I suggest you check out BakedGoods. With it, placing one or more data items in an IndexedDB database, for example, is as simple as:

bakedGoods.set({
    data: [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}],
    storageTypes: ["indexedDB"],
    function(byStorageTypeStoredItemRangeDataObj, byStorageTypeErrorObj){}
});

Of course, if you're some sort of masochist, you could ignore my suggestion and deal with the raw API. But don't say I didn't warn you !

For the sake of complete transparency, BakedGoods is maintained by yours truly :) .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.