Sobre Local Storage

Asked

Viewed 253 times

0

Good night! I’m doing a job for the college that’s an online store. Well, I wasn’t able to get the buy button to send to the "shopping cart" page until a friend told me about Local Storage, the problem is I’ve never seen anything about, can anyone give me a hand? I’m doing it in html, I already have the buy button, I need to make it send the product information (price, name) to the shopping cart and after I get there it adds the prices, if you have more than one product. Note: I am beginner. Thank you!

1 answer

2

Local Storage is a local data persistence feature that has been available since HTML5. This means that newer browsers should have support.

When I say local data persistence, I am meaning that you will save the data in the person’s browser without having to persist in a database that is on your server.

Local Storage saves strings by default, but nothing stops you from serializing Jsons and storing them as strings.

Since this is a college project, I don’t know how demanding your teacher will be. If it were in a real scenario, I believe that Local Storage would not be the ideal technology to implement a shopping cart.

You can understand more about Local Storage here: https://developer.mozilla.org/en-US/docs/Web/API/Window/Window.localStorage

Browser other questions tagged

You are not signed in. Login or sign up in order to post.