express cookie session code example
Example 1: express get cookie
const cookieParser = require('cookie-parser');
const express = require('express');
const app = express();
app.use(cookieParser());
app.get('/', (req, res) => {
console.log('Cookies: ', req.cookies);
console.log('Signed Cookies: ', req.signedCookies);
});
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: [/* secret keys */],
// Cookie Options
maxAge: 24 * 60 * 60 * 1000 // 24 hours
}))