how to add cookies and seesion to rest api node code example
Example 1: express cookies
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();
app.use(cookieParser());
app.get('/', (req, res) => {
res.send(req.cookies);
});
app.listen(3000);
Example 2: experss cookie session
var cookieSession = require('cookie-session')
var express = require('express')
var app = express()
app.use(cookieSession({
name: 'session',
keys: [],
maxAge: 24 * 60 * 60 * 1000
}))