Answer the question
In order to leave comments, you need to log in
How to work with cookies in nodejs?
Good afternoon! :)
Tell me how to work with cookies in a node?
Cookies are already stored in cookie
, you need to count them and parse them by key: value, and how to work with all this?
In jQuery I do this:
var cook = JSON.parse($.cookie("cook"));
for (var key in cook) {
console.log(cook[key].field);
}
app.post('/', function (req, res) { ... }
Answer the question
In order to leave comments, you need to log in
app.post('/', function (req, res) { ... }
this means you are (most likely) using express.
If yes, then use this cookie-parser
Like mine in index.js
var cookieParser = require('cookie-parser');
...
app.use(cookieParser());
app.post('/', function(req, res) {
console.log("Cookies: ", req.cookies)
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question