HTML5 - Data saving options

Hello everyone,

I’m quite new to OpenFl and Haxe and currently try to realise a multi-platform game. My main target for now is HTML5 as the game has to run on desktop and mobile and should also work without an internet connection.
I need to store data generated during the game preferably as a SQLite database, but now have the problem that with HTML5 I cannot access the local file system as far as I understood.

So is there a way to store data locally without an internet connection, perhaps even as a SQLite database with HTML5? And if not, are there other ways of storing data that could be easily converted back to an SQL compatible format?

Thanks a lot for any help on this!

Only way I know of to use sqlite storage for html5 is by using a web socket and connecting to a server with the ability to accept a web socket connection and read and write to database. So your best option If you want offline would be to use cookies, and you could serialize them in order to input dynamic data into them.

Here’s a good article:

https://www.html5rocks.com/en/features/storage

openfl.net.SharedObject uses Web Storage

1 Like

Thanks a lot for the answers and the link!

Using a SharedObject sounds like it could do the trick and also seems to be close to the cookies idea if I’m not mistaken.
So if I understood that correctly, I could serialize my data using for example haxe.Json.stringify and pass it on to a local shared object. Is it then possible to deserialize it again and get a database object that can be written to a SQL database as soon as the device is online again?

If you can go to/from JSON, then certainly. There is a default size limit per website (unless you prompt the user and they allow more space), but for small sizes, it works great :slight_smile:

Awesome, thanks a lot! Then I will try this and see if I can implement it :slightly_smiling_face: