如何在Azure函数中使用cookie HttpTriggers(Node)

时间:2018-04-25 16:46:49

标签: node.js azure azure-functions

我看到请求对象的headers属性中有一个'cookie'键,但没有别的。

我无法在文档中找到与cookie相关的任何内容。

module.exports = function (context, req) {

  context.res = {
    body: "Something"
  };

  // how do I send cookies ??

  context.done();
} 

1 个答案:

答案 0 :(得分:0)

在标题中使用Set-Cookie应该有效。

例如:

var exdate = new Date(2018, 5, 1);
context.res = {
    body: "<b> this totally works</b> <i> nice</i>",
    status: 201,
    headers: {
        'Set-Cookie': 'mycookie=test; Expires=' + exdate.toUTCString() + ';'
    }
};
context.done();