How to set cookie secure flag using javascript

前端 未结 3 1533
慢半拍i
慢半拍i 2020-12-30 18:40

I have tried to set a cookie using document.cookie = \"tagname = test; secure\" but this does not set the secure flag. Am I setting it wrong? Can you only set i

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 19:00

    because the flag is called secure, not security:

    document.cookie = "tagname = test;secure";
    

提交回复
热议问题