feat: Delete duplicate cookies with the same name in getCookie function
This commit is contained in:
parent
cf950313fc
commit
5abf9ec190
|
@ -305,8 +305,9 @@ export function removeCookie(cName: string): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCookie(cName: string): string {
|
export function getCookie(cName: string): string {
|
||||||
if (document.cookie.indexOf(cName) !== document.cookie.lastIndexOf(cName)) {
|
// check if there are multiple cookies with the same name and delete them
|
||||||
document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
if (document.cookie.split(";").filter(c => c.includes(cName)).length > 1) {
|
||||||
|
removeCookie(cName);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
const name = `${cName}=`;
|
const name = `${cName}=`;
|
||||||
|
|
Loading…
Reference in New Issue