From cf950313fcac013ae057d8536ba64715a4a22db7 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Sun, 21 Jul 2024 16:08:51 +0100 Subject: [PATCH] feat: Improve cookie handling in getCookie function --- src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index c6f35526ce5..3307e5e70a5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -305,6 +305,10 @@ export function removeCookie(cName: string): void { } export function getCookie(cName: string): string { + if (document.cookie.indexOf(cName) !== document.cookie.lastIndexOf(cName)) { + document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Expires=Thu, 01 Jan 1970 00:00:00 GMT`; + return ""; + } const name = `${cName}=`; const ca = document.cookie.split(";"); for (let i = 0; i < ca.length; i++) {