// in terminal:
npm install cookie-parser
// in your javascript file:
const cookieParser = require("cookie-parser");
app.use(cookieParser());
app.get('/', (req, res)=> {
const {visitor_name} = req.cookies
if(visitor_name) {
res.send(`Hello ${visitor_name}`) // saved cookie visitor_name
} else {
res.send(`I do not remember you!`) // no cookies saved
}
})
let last_visit = req.cookies['last_visit'];