简体   繁体   English

Cookie不能在nodeJS的服务器端设置

[英]Cookie can't be set server-side with nodeJS

I use the simple way to create cookie but it just doesn't work. 我使用简单的方法来创建cookie,但它不起作用。

My code is like this : 我的代码是这样的:

router.post('/auth', function(req, res, next){
    ...

       res.cookie('access_token', 'test')

       console.log(req.cookies)

    ...
})

I can get the token client-side. 我可以获得令牌客户端。 But the console.log says 'undefined' 但是console.log说'undefined'

Problem solved. 问题解决了。

I used library 'Cookies' from npm. 我从npm使用了库'Cookies'。 It works fine. 它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM