Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

cookie parser

// in terminal: 
npm install cookie-parser
// in your javascript file:
const cookieParser = require("cookie-parser");
app.use(cookieParser());

app.get('/', (req, res)=> {
  const {visitor_name} = req.cookies
  if(visitor_name) {
    res.send(`Hello ${visitor_name}`) // saved cookie visitor_name
  } else {
    res.send(`I do not remember you!`) // no cookies saved
  }
})
 
PREVIOUS NEXT
Tagged: #cookie #parser
ADD COMMENT
Topic
Name
9+3 =