From 5e87b3d2d3f143ed9df5f9e55c5863ea72220c1f Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 24 Apr 2024 17:08:32 +0100 Subject: [PATCH] Fixed check to not use cookies and use localStorage instead --- static/js/main.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index ad16508..4b102ca 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -609,23 +609,19 @@ function exportNotes() { } function isFirstTimeVisitor() { - if (document.cookie.indexOf("visited=true") !== -1) { - return false; - } else { - var expirationDate = new Date(); - expirationDate.setFullYear(expirationDate.getFullYear() + 1); - document.cookie = "visited=true; expires=" + expirationDate.toUTCString() + "; path=/; SameSite=strict"; + if (localStorage.getItem("FIRSTVISIT") === null) { + localStorage.setItem("FIRSTVISIT", "1") return true; + } else { + return false; } } function firstNewVersion() { - if (document.cookie.indexOf("version=1.2") !== -1) { + if (localStorage.getItem("NEWVERSION") == "1.2") { return false; } else { - var expirationDate = new Date(); - expirationDate.setFullYear(expirationDate.getFullYear() + 1); - document.cookie = "version=1.2; expires=" + expirationDate.toUTCString() + "; path=/; SameSite=strict"; + localStorage.setItem("NEWVERSION", "1.2") return true; } }