设置未在浏览器中设置的Cookie

时间:2017-09-11 07:25:47

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

我正在使用AWS Lambda函数设置和API网关。我一直在尝试为应用程序设置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

2 个答案:

答案 0 :(得分:1)

将s3存储桶托管的静态网站更改为API网关后,传递了cookie

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Cookies.html

答案 1 :(得分:0)

尝试设置Cookie的路径

Set-Cookie:myCookie=foo; Path=/; HttpOnly
相关问题