【问题标题】:samesite is not working for ngcookies in Angular JSsamesite 不适用于 Angular JS 中的 ngcookies
【发布时间】:2020-01-29 03:37:09
【问题描述】:

我正在为我的 Angular JS 项目使用 ngCookies。我正在尝试将 samesite 选项设置为严格(如下所述),但它不起作用。谁能帮助我如何为 Angular JS cookie 设置相同站点?

我按照这个 Angular JS 文档进行了尝试,我看到所有其他选项都已设置,但同一站点未在 chrome 中设置为“严格”。 Reference

MyCookiesService.put('user-details', JSON.stringify(session), {
                        expires: expire.toUTCString(),
                        path: '/',
                        secure: true,
                        samesite: 'strict'
                    });

【问题讨论】:

  • 我怀疑问题出在我正在使用的 Angular JS 版本(1.6.10)上。从 1.7.1 版本开始支持 samesite 选项。

标签: angularjs cookies samesite


【解决方案1】:

通过Nirmala 的评论解决。

我的问题需要samesite: 'none'。升级到 Angular 1.7.1+ 后确认的代码可以正常工作

MyCookiesService.put('user-details', JSON.stringify(session), {
                        expires: expire.toUTCString(),
                        path: '/',
                        secure: true,
                        samesite: 'strict'
                    });

【讨论】:

    猜你喜欢
    • 2020-06-29
    • 2015-11-18
    • 1970-01-01
    • 2014-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多