I use React SPA, Express, Express-session
In this case I have successfully created a shopping cart. I store this data Carts based on the sessionID from the express session which is unique in mysql database.
but I don't know whether this method is correct?
So I store it based on the sessionID user, when the user visits the website, the sessionID will be stored in the database mysql table session. so when doing add to cart the stored data is related to the session.
Table carts
id session_id
1 cfcf05e9-f4de-4796-835d-237f525b9c67
Table session
id ipaddress
cfcf05e9-f4de-4796-835d-237f525b9c67 127.0.0.1
Table cart_items
id product_id product_variant_id cart_id quantity
1 5 5 1 5
I have checked the cookies, and it turns out that the sessionID is stored in cookies named cookies.sid.
Do I still need different cookies tokens for shopping carts?and how if I use authentication like login? how to connect it