Setting a Cookie using only HTML5

后端 未结 2 1392
野的像风
野的像风 2021-01-16 05:04

I found this article where it explains how to set a cookie using only HTML.

He use http-equiv attribute on the in the &l

相关标签:
2条回答
  • 2021-01-16 05:13

    You used to be able to set cookies using a mata tag, however browsers are moving away from that in favour of HTTP headers, or document.cookie.

    If you try to set a cookie using meta tags in Chrome, you will get a warning and/or error (Depending on your version). The feature has been deprecated in M63, and completly removed in M65.

    [Deprecation] Setting cookies via <meta http-equiv='Set-Cookie' ...> no longer works, as of M65. Consider switching to document.cookie = ..., or to Set-Cookie HTTP headers instead. See https://www.chromestatus.com/feature/6170540112871424 for more details.

     

    Blocked setting the Example cookie; path=/; expires=Friday, 24-Mar-18 10:00:00 GMT cookie from a <meta> tag.

    I would imagine that other browsers also have this feature deprecated/removed, or will follow suit shortly with chrome.

    You can read more about the deprecation of this feature here: https://bugs.chromium.org/p/chromium/issues/detail?id=767813

    0 讨论(0)
  • 2021-01-16 05:21

    Don't set cookies in HTML with meta http-equiv="set-cookie". It's outdated and has no effect in modern browsers that follow the current HTML5 standard (it's non-conforming in HTML5).

    0 讨论(0)
提交回复
热议问题