Wednesday, 6 March 2019

Express: req.cookies: Get the cookies associated with this request


This property represents an object that contains cookies sent by the request. You should use cookie-parser middleware to access cookies.

index.js
const express = require('express')
var cookieParser = require('cookie-parser')

const app = express()

app.use(cookieParser()); 

app.get('/', (req, res) => res.send("Hello World"))

app.get('/users', (req,res) => {
 res.send(req.cookies)
})

const port = 3000
app.listen(port, () => console.log(`Application started listening on port ${port}!`));



Previous                                                 Next                                                 Home

No comments:

Post a Comment