amazon-web-services - 设置Cookies,不要在浏览器中设置

标签 amazon-web-services cookies aws-lambda setcookie

我正在将 AWS Lambda 函数设置与 API Gateway 结合使用。我一直在尝试为应用程序设置 cookie,但即使它显示在控制台标题中,它也没有在浏览器中设置。

  callback(null, {
        statusCode: 302,
        headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS',
            'Location': "https://example.com",
            'Set-Cookie': cookieString,
            'Content-Type': 'application/json'


        },
        body: null
    } );

https://aws.amazon.com/blogs/compute/simply-serverless-using-aws-lambda-to-expose-custom-cookies-with-api-gateway/ 尝试实现此功能,但在浏览器中未设置 cookie。 enter image description here

enter image description here

最佳答案

尝试设置 Cookie 的路径:

Set-Cookie:myCookie=foo; Path=/; HttpOnly

关于amazon-web-services - 设置Cookies,不要在浏览器中设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46150293/

相关文章:

android - 如何在 Amplify for Android 中将 Cognito 身份池与 UnAuthenticad 用户一起使用

javascript - 如何用JavaScript判断是否不存在这样的cookie?

node.js - Phantomjscloud 无法与 aws lambda nodejs 一起使用

amazon-web-services - Security Hub - AWS 基础安全最佳实践 - S3.2 S3 存储桶应禁止公共(public)读取访问

amazon-web-services - AWS 负载均衡器 ELB 的 ssl 终止是否安全?

amazon-web-services - 数据库迁移任务无法将数据加载到源数据库中

c# - HttpWebRequest 丢失 cookie

javascript - 如何在没有 javascript 的情况下在客户端创建 cookie?

python - 在AWS lambda函数中使用scrapy作为层

java - AWS API Gateway 自定义授权方 lambda