Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles

HTML5 game : Save data locally

A topic by Acid Prank created Jan 26, 2018 Views: 529 Replies: 3
Viewing posts 1 to 4

Hi, 

I'm wondering if it is possible to save data client side or even server side (I doubt for this one) ? 

I did a quick search and it seems that it is possible to save some data locally : 

https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#localStorage 

Does someone already did on a HTML5 Game here ?  some experience to share ? 

Moderator (1 edit) (+1)

I can tell you that you're on the right tracks. Local storage is the way to go, so go ahead read on that :)

As for my experience, I did a bit of web games years ago when HTML5 wasn't a thing - so you'd usually go for cookies to save and load data. Cookies were very easy to implement but are a mess to work with.

Admin(+1)

You can use local storage to save data. We currently have an issue where uploading a new build of your game changes the path it lives on, so you might lose your storage depending on how you've saved it.

(3 edits)

I haven't yet tried local storage, but considering this line from the docs "accesses the current domain's local Storage", I worry it doesn't work after "updating" a game (deleting an old file, uploading a new file to a new, randomized directory).

Please correct me if I'm wrong, but wouldn't an update button on an existing file in the dashboard solve this problem? Instead of only new files, or deleting existing files, what about "overwriting" existing files? Keep the old directory the file lives in, delete the contents, and then upload new contents to said directory. This way concepts like PlayerPrefs in Unity's WebGL builds would work. 

I'll try interfacing with local storage from a Unity WebGL build later and update this post if it works for me.

Thanks.