On my client-side I'am saving a token in the user's cookies :
this.socket.on('server:authentication', function(tokenObject){
if(tokenObject){
sessionStorage.setItem("token", tokenObject);
this.setState({ submitted: true});
}
}.bind(this));
Then I want to read that token on the server side, but when I do :
app.use(cookieParser());
app.use(function(req, res, next){
const { token } = req.cookies;
console.log(token);
...
});
I get "undefined" on the console. Same thing when I try console.log(req.cookies.token)
. How can I achieve that?
via Mit
No comments:
Post a Comment