res.cookie express code example

Example 1: express redirect

res.redirect('/foo/bar')
res.redirect('http://example.com')
res.redirect(301, 'http://example.com')
res.redirect('../login')

Example 2: 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 3: http header express

app.get('/', (req, res) => {
  req.header('User-Agent')
})
// Use the Request.header() method to access
//one individual request header’s value