node下控制Cookie
安装中间件
npm install
cookie-parser
引入
app.use(require('cookie-parser')());
app.use(require('cookie-parser')(Math.ceil(Math.random()*100000000));
设置
调用res.cookie('name', 'admin'); res.cookie('sid', 'yyxx', { signed: true });
res.cookie('name', loginname, { maxAge: 2*3600 });
var name = req.cookies.name; var
sid
= req.signedCookies.
sid
;
移除
res.clearCookie('monster');