From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Session cart ID

Session cart ID

All right guys, so we have our add to cart component and if I click it it calls the action But all the action does is sends back a successful response no matter what and we see this toast pop-up It's not actually doing anything. We haven't implemented any any cart logic yet so what I want to do in this particular video is make it so that when we come to the website a session cart ID is Generated and a cookie is created. That's why I have at the application tab open and cookies, and I'm not logged in that's why we don't see the session cookie here and What I want to happen is again when we come to the site, it'll create this session Cart ID cookie, which will be just a UUID value And then we can use that in our action later to basically connect the user to their cart whether they're logged in or not That's why we want it to run as soon as they come to the website And we want that added, whether they're logged in or not. Now, where we're going to do this is in a callback that we're…

Contents