hannah-finch / isabelles-bead-shop

E-commerce site for a small jewelry shop
MIT License
3 stars 1 forks source link

Attach Cart persistence to Login Token, or DB #120

Open swokamoto opened 1 month ago

swokamoto commented 1 month ago

Currently the cart is stored in local storage. If the user is logged out automatically, the cart items will remain on the local machine. This would only be an issue if there were multiple users on the same system that were both wanting the change the cart on their individual accounts.

Option1: append a user ID ( some unique identifier ) to the name of the local storage item Option2: store the cart in the DB, but this may require excessive network requests. Maybe just use this to save the logout state of the info, and then restore it when the user logs in from any location. that would override any cart items the user had if they were to add them while NOT logged in, and then logged in.