I am working on express/node.js and trying to understand cookies of expressjs and I'm setting cookie like this:
var express = require('express');
var app = express();
var cookieParser = require('cookie-parser');
app.use(cookieParser());
app.get('/', function(req, res){
res.cookie('cookie1', 'This is my first cooke', {maxAge: 1000*60*60*24*7, httpOnly: true});
res.end('Cookie has been set');
});
And accessing cookies as follows:
app.get('/readCookies',function(req, res){
res.send(req.cookies.cookie1);
});
But the problem is signed: true option when including this one for encoding cookie value during setting the cookie I am getting the following error:
Error: cookieParser("secret") required for signed cookies
Please help me and thanks in advance