最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

重定向到新的子域并在重定向的子域上设置cookie

IT培训 admin 12浏览 0评论

重定向到新的子域并在重定向的子域上设置cookie

Express:4.x

NodeJS:12.x

a.example上,我有一个GET侦听器,该侦听器重定向到b.example,并在b.example上设置cookie。

app.get('/foo', (req, res) => {
    res.cookie('name', 'foo', { domain: '.example', path: '/', secure: true })
    res.cookie('age', '21', { domain: '.example', path: '/', secure: true })
    res.redirect(302, '');
})

但是在b.example中未设置任何cookie。我在这里想念什么?

回答如下:

好,所以我想出了答案。从domain中删除res.cookie选项是有效的。

重定向到新的子域并在重定向的子域上设置cookie

Express:4.x

NodeJS:12.x

a.example上,我有一个GET侦听器,该侦听器重定向到b.example,并在b.example上设置cookie。

app.get('/foo', (req, res) => {
    res.cookie('name', 'foo', { domain: '.example', path: '/', secure: true })
    res.cookie('age', '21', { domain: '.example', path: '/', secure: true })
    res.redirect(302, '');
})

但是在b.example中未设置任何cookie。我在这里想念什么?

回答如下:

好,所以我想出了答案。从domain中删除res.cookie选项是有效的。

发布评论

评论列表 (0)

  1. 暂无评论