Save/load persistence in HTML5 build (SOLVED)

It seems that while sys.save and sys.load work in the HTML5 build, the saved data does not survive page reload.

I would expect the engine to save my game’s data to the local storage…

Thanks for the report. I’m filing an issue on this.
DEF-1522

1 Like

So has it been done. I mean how do I store the game data in my local storage? There are no proper documents present which discuss this topic

I think there might be some limitations on certain browsers, but I’m not 100% sure. Is it not working in any browser? @Ragnar_Svensson might know more.

Have you figured out something? @sicher @britzl @Ragnar_Svensson

I need to have a simple storage so I’ve tried sys.save and as @agladysh mentioned it doesn’t survive reload.
Local storage would be perfect for my needs. The only other solution I see is to implement a simple backend?

I’ve tried in Safari and Chrome.

I checked the Jira ticket @sicher created, but it hasn’t been assigned a priority yet. Hopefully we’ll be able to provide more information and an estimated delivery date once @Ingela_Garneij and the rest of the team is back.

1 Like

Any progress with this bug?

I must have a way of storing simple data on my html5 game…

Persistent storage was added in version 1.2.80, but there can be some limitations and issues with this related to browser and user settings, so it’s always preferred to store player data server side if possible. (Marking this issue as solved.)

I need a way to store the userId client side… using Defold 1.2.99 and latest chrome seems that it’s still not working.
Any other way I can store the user id to survive browser refresh?

UPDATE:
Resolved this by using

 sys.get_save_file

instead of just using a string as a file name.

1 Like

As long as you use sys.get_save_file() to get the path to a location that is intended for app specific persisted data then it should be ok to use sys.save() and all of the io.* functions on all supported platforms.

2 Likes