Hello SO,
My server uses Node.js and Express. I have properly set up cookie-parser and body-parser and I can receive and send cookies most of the time.
So, my app is very basic actually.
- Login page is presented.
- Ajax request to
sesloginwithidToken and csrfToken. - Backend receives this tokens and can read cookies from
req. - Creates session cookie and sends it to client.
- Client redirects to
/profilewithwindow.location.assign('profile') - Normally backend reads session cookie, verify it and present a UI.
In my app.ts, I can receive cookies perfectly in this part. I'm calling seslogin with an Ajax request on my client script.
app.post('/seslogin', function (req, res) {
// Get ID token and CSRF token.
const idToken = req.body.idToken.toString();
const csrfToken = req.body.csrfToken.toString();
console.info('[SESLOGIN] Cookies: ', req.cookies);
console.info('[SESLOGIN] Session Cookie: ', req.cookies.session);
...
...
});
However, very interestingly in this part cookies are undefined
app.get('/profile', function (req, res) {
// Get session cookie.
const sessionCookie = req.cookies.session || '';
console.info('[PROFILE] Cookies: ', req.cookies);
console.info('[PROFILE] Session Cookie: ', req.cookies.session);
//Test purposes
res.send(req.cookies).end();
...
});
Aucun commentaire:
Enregistrer un commentaire