This contrived example uses
document.cookie
to modify the page's cookies via JavaScript, as an alternative to using the
Set-Cookie:
HTTP response header.
Here are the cookies set for the current page:
Available in Chrome 49+ | View on GitHub | Browse Samples
As described in an Internet Engineering Task Force draft, Cookie Prefixes are a way of "smuggling" information in the name prefix of a cookie to ensure that certain attributes accompany the request to set a cookie. The supported prefixes are:
__Secure-
, which signals to the browser that the
Secure
attribute
is required.
__Host-
, which signals to the browser that both the
Path=/
and Secure
attributes
are required, and at the same time, that the Domain
attribute
must not be present.
The __Secure-
and __Host-
name prefixes do not
have any special meaning to browsers that don't support Cookie Prefixes, so
you cannot count on those prefixes providing assurances across all browsers.
This contrived example uses
document.cookie
to modify the page's cookies via JavaScript, as an alternative to using the
Set-Cookie:
HTTP response header.
Here are the cookies set for the current page: