Set cookie on document host by removing domain

Cookies using the hostname as a domain will be set
with a prefix of `.` by browsers, it seems to
ensure all subdomains are included in the scope.

When deleting the `seen_cookie_message` cookie we
want to set its domain without a `.` prefix, to
match the domain set by the original code.

Leaving the `domain` attribute out from the cookie
string will ensure the `.` prefix is not set.
This commit is contained in:
Tom Byers
2020-01-23 12:07:18 +00:00
parent d68403f7dc
commit 6c2af9e696

View File

@@ -9,7 +9,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
// clear old cookie set by our previous JS, set on the www domain
if (window.GOVUK.cookie('seen_cookie_message')) {
document.cookie = 'seen_cookie_message=;expires=' + new Date() + ';domain=' + window.location.hostname + ';path=/';
document.cookie = 'seen_cookie_message=;expires=' + new Date() + ';path=/';
}
if (consent === null) {