Store data in the browser

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By EnrikeChurin

How can I store data in the browser if a game is exported for HTML5? Where does user:// save data (cookies, indexeddb, cache api)? And how much space is available?

:bust_in_silhouette: Reply From: klaas

Hi.
The docs say:

Using cookies for data persistence

Users must allow cookies (specifically IndexedDB) if persistence of
the user:// file system is desired. When playing a game presented in
an iframe, third-party cookies must also be enabled. Incognito/private
browsing mode also prevents persistence.

The method OS.is_userfs_persistent() can be used to check if the
user:// file system is persistent, but can give false positives in
some cases.

so i would say the data gets stored in IndexedDB.

Best you try it out. Save your game in chrome, then hit F12, goto Application → Storage

Thanks, it’s only 5-50 MiB though, so I can’t do much (making a digital audio workstation).

EnrikeChurin | 2021-08-19 14:48

just found out … you can get the allowed space with javascript

Hit F12 open console, paste, enter

quota = await navigator.storage.estimate();console.log(quota.quota);

klaas | 2021-08-19 14:54

Thanks
need to have 12 characters lol

EnrikeChurin | 2021-08-19 14:57