I always set cookies in express.js by executing command,
res.cookie("name", "value");
But when I close the browser and open again, I saw there is no such cookie.
How can I keep remain cookies forever even if I close the browser? Please help me.
I think you are using cookie-parser package. And for expiration, just use maxAge attribute.
res.cookie("myCookie", true, {
maxAge: 1000*60*60*24
});
1000 miliseconds*60 seconds * 60 mins * 24 hour = 1 day. Your cookie will stay in your browser for one day.