From 5abf9ec190a4eba4b206b1f3fdd3f41304974146 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Sun, 21 Jul 2024 16:30:53 +0100 Subject: [PATCH] feat: Delete duplicate cookies with the same name in getCookie function --- src/utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 3307e5e70a5..3d55ab8fc65 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -305,8 +305,9 @@ 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`; + // check if there are multiple cookies with the same name and delete them + if (document.cookie.split(";").filter(c => c.includes(cName)).length > 1) { + removeCookie(cName); return ""; } const name = `${cName}=`;