Cookie doesn't set with 'secure' flag on HTTPS - JavaScript

0 投票
最新提问 用户: (1.4k 分)

I'm trying to set document.cookie with secure flag, like this:

document.cookie = 'token=hR_lVjFDKAUbuRRKmNCSZ3mlvpcWi1sA; expires=Fri, 31 Dec 9999 23:59:59 GMT; domain=https://my-secured-fake-site.com; path=/; secure';

But it doesn't work at https://my-secured-fake-site.com (which equals to domain attribute in desirable cookie string). Please help to understand what's wrong.

发表于 用户: (220 分)
the secure come has come secured from the server that cannot be set on the client

1个回答

0 投票
最新回答 用户: (1.4k 分)

It was my fault. I need to set domain as my-secured-fake-site.com instead of https://my-secured-fake-site.com as I tried before.

欢迎来到 Security Q&A ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。
...