Can anybody explain to me how to use cookies with the MERN stack? I'm trying to make an analog for social media. I understand first steps but then - I don't know how to proceed.
- I create endpoints for login, register, logout.
- I create react app and made register form, login form. And from there - I'm sending axios request to my express endpoints.
- In express - I'm saving to MongoDB user or checking login + password from DB.
- I'm creating a JWT token with id payload and sending it via cookie.
But what do I do next? How to save which user is logged in in the react app? And how do I check if the user is still logged in and the cookie exists? Thanks for any help!