diff --git a/src/client/assets/javascripts/cookie-functions.js b/src/client/assets/javascripts/cookie-functions.js index 5288feb..daa072d 100644 --- a/src/client/assets/javascripts/cookie-functions.js +++ b/src/client/assets/javascripts/cookie-functions.js @@ -344,6 +344,7 @@ function deleteCookie(name) { // If a cookie was set with a specified domain, it needs to be specified when deleted // If a cookie wasn't set with the domain attribute, it shouldn't be there when deleted // You can't tell if a cookie was set with a domain attribute or not, so try both options + document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/` document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=${window.location.hostname};path=/` document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=.${window.location.hostname};path=/` diff --git a/src/client/assets/javascripts/cookies-page.js b/src/client/assets/javascripts/cookies-page.js index 257246f..a631b26 100644 --- a/src/client/assets/javascripts/cookies-page.js +++ b/src/client/assets/javascripts/cookies-page.js @@ -1,8 +1,4 @@ -import { - getConsentCookie, - setConsentCookie, - Cookie -} from './cookie-functions.js' +import { getConsentCookie, setConsentCookie } from './cookie-functions.js' /** * Website cookies page @@ -76,7 +72,6 @@ class CookiesPage { savePreferences(event) { // Stop default form submission behaviour event.preventDefault() - let item const preferences = {} this.$cookieFormFieldsets.forEach(($cookieFormFieldset) => { @@ -89,25 +84,28 @@ class CookiesPage { `input[name="cookies[${cookieType}]"]:checked` ) - item = $selectedItem.value if ($selectedItem instanceof HTMLInputElement) { preferences[cookieType] = $selectedItem.value === 'yes' } }) - if (item === 'yes') { - // Save preferences to cookie and show success notification - setConsentCookie(preferences) - } else { - for (const UACookie of [ - '_ga_HVF94VF4NZ', - '_gid', - '_ga', - 'phi_cookies_analytics' - ]) { - Cookie(UACookie, null) - } - } + + // Save preferences to cookie and show success notification + setConsentCookie(preferences) + + // for (const UACookie of [ + // '_ga_HVF94VF4NZ', + // '_gid', + // '_ga', + // 'phi_cookies_analytics' + // ]) { + // Cookie(UACookie, null) + // } + this.showSuccessNotification() + const cookieBanner = document.querySelector( + "[data-module='govuk-cookie-banner']" + ) + cookieBanner.setAttribute('hidden', 'true') } /**