Cookies not getting set in node.js
<p>Im trying to set cookies for my website using node.js and express.js. Heres a simplified version of my code:</p>

<pre><code>var express = require('express');
var cookieParser = require('cookie-parser');

var app = express();
app.use(cookieParser());

app.post('/testCookies', function(req, res) {
   console.log(req.cookies); //empty object
   res.cookie('username', 'test');
   console.log(req.cookies); //still an empty object

   res.end();
});
</code></pre>

<p>I tried POSTing twice in case the cookies somehow get set after the request (im not very familiar with cookies yet) but it doesn't change anything. The console does not show any errors.</p>