Skip to content

Commit

Permalink
No longer request cookies if the user has refused
Browse files Browse the repository at this point in the history
  • Loading branch information
Romitou committed May 9, 2024
1 parent da86ac7 commit 4602522
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/templates/js/functions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
let isCookiesAccepted = getCookie("cookies-accepted") === "true";

// <> Cookies

// Returns whether the user has accepted the cookies or not, or undefined if the user hasn't chosen yet
function isCookiesAccepted() {
const cookie = getCookie("cookies-accepted");
if (!cookie) {
return undefined;
}
return Boolean(cookie);
}

function setCookie(cname, cvalue, exdays, force = false) {
if (!isCookiesAccepted && !force)
if (!isCookiesAccepted() && !force)
return;

const d = new Date();
Expand Down Expand Up @@ -37,7 +45,7 @@ function getCookie(cname) {
* @param {double} exdays time in days
*/
function setStorageItem(item, value, exdays, force = false) {
if (!isCookiesAccepted && !force)
if (!isCookiesAccepted() && !force)
return;

const d = new Date();
Expand Down

0 comments on commit 4602522

Please sign in to comment.