mardi 12 janvier 2021

How can I let user can add items to their cart without logging in to website in Laravel?

Now I'm creating an e-commerce website. On that website, I'm going to let the user add the product to her/his cart without logging in.

It works as usual:

  1. User visits the website and adds a product to her/his cart
  2. If he/she logs in or register, cart items stays the same.
  3. If he/she leaves and will come back later, cart items stay the same even though he/she doesn't log in.

Right now, I'm storing a cookie in every user's browser and creating a new user in the database. Every time when a user visits, I'm checking a cookie if it exists, I'm searching user data based on that.

Is this method is right? If it is. How can I implement it in Laravel? Now I'm using Vue.js and checking every time and retrieving data from the database.

Aucun commentaire:

Enregistrer un commentaire