diff options
author | Andreas Schnederle-Wagner <schnederle@futureweb.at> | 2022-07-21 16:24:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-21 16:24:42 +0300 |
commit | 06b431bdecb630f89b507eb8eebfd8e35ea7e099 (patch) | |
tree | 0f38e02b343d96ed704a9b008486a913200ef625 /js/piwik.js | |
parent | e459f3cc12758fdab09fe9182f28584276a1f9fe (diff) |
Implement cookie expire time - forgetConsentGiven (#19532)
* Implement cookie expire time - forgetConsentGiven
Implement Feature Request #19530
* Implement cookie expire time - forgetConsentGiven
* Implement cookie expire time - forgetConsentGiven
* Implement cookie expire time - forgetConsentGiven
* forgetConsentGiven cookie expire Param description
Diffstat (limited to 'js/piwik.js')
-rw-r--r-- | js/piwik.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/js/piwik.js b/js/piwik.js index 5af350389b..274d4ea4ac 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -7218,16 +7218,25 @@ if (typeof window.Matomo !== 'object') { }; /** - * Calling this method will remove any previously given consent and during this page view no request - * will be sent anymore ({@link requireConsent()}) will be called automatically to ensure the removed - * consent will be enforced. You may call this method if the user removes consent manually, or if you - * want to re-ask for consent after a specific time period. - */ - this.forgetConsentGiven = function () { - var thirtyYears = 30 * 365 * 24 * 60 * 60 * 1000; + * Calling this method will remove any previously given consent and during this page view no request + * will be sent anymore ({@link requireConsent()}) will be called automatically to ensure the removed + * consent will be enforced. You may call this method if the user removes consent manually, or if you + * want to re-ask for consent after a specific time period. You can optionally define the lifetime of + * the CONSENT_REMOVED_COOKIE_NAME cookie in hours using a parameter. + * + * @param int hoursToExpire After how many hours the CONSENT_REMOVED_COOKIE_NAME cookie should expire. + * By default the consent is valid for 30 years unless cookies are deleted by the user or the browser + * prior to this + */ + this.forgetConsentGiven = function (hoursToExpire) { + if (hoursToExpire) { + hoursToExpire = hoursToExpire * 60 * 60 * 1000; + } else { + hoursToExpire = 30 * 365 * 24 * 60 * 60 * 1000; + } deleteCookie(CONSENT_COOKIE_NAME, configCookiePath, configCookieDomain); - setCookie(CONSENT_REMOVED_COOKIE_NAME, new Date().getTime(), thirtyYears, configCookiePath, configCookieDomain, configCookieIsSecure, configCookieSameSite); + setCookie(CONSENT_REMOVED_COOKIE_NAME, new Date().getTime(), hoursToExpire, configCookiePath, configCookieDomain, configCookieIsSecure, configCookieSameSite); this.forgetCookieConsentGiven(); this.requireConsent(); }; |