Save and load information in JS permanently

I need save and load information of my web page in the PC, I need my info to be saved even if the PC is turned off, the localStorage keeps the info until the PC is turned off.
PD: Sorry for my English, I am learning.

if you have very little information, you can put it in a cookie, but that’s not very robust.

Generally, you’ll want to use IndexedDB, which is designed specifically for saving (and reloading data). This API is not very convenient/beginner-friendly so you may want to use a framework designed upon it, such as Dexie.

1 Like

You might confuse localStorage with sessionStorage. 

The first does never expire, while sessionStorage is linked to the session.

The read-only localStorage property allows you to access a Storage object for the Document’s origin; the stored data is saved across browser sessions. localStorage is similar to sessionStorage, except that while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends — that is, when the page is closed – MDN

IndexedDB as suggested is another suitable storage, especially with large amounts of data.

1 Like

Thanks, you know a course/tutorial of Dexie, I read the official website of Dexie and I didn’t understand the tutorial.

Just to follow up on what @gowritesoftware mentions above, the Local Storage API is most likely what you’d want to be looking into. The API itself is as straightforward as it gets, however, what is your definiton of “permanently” exactly? As I’m sure you’re aware, any client-side storage technologies are at the mercy of the client themselves, who could potentially modify or delete whatever data you’re storing. Does that matter to the overall goal and intent of the project at all?

The proyect is how an agenda, but i need save the information in the user’s PC. i used localStorage, but when i restard the PC the info is erased.