diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index 5a9ed4691..2dd8006fb 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -57,9 +57,16 @@ export function getCookieDomainValue() { Returns empty string if cookie not found or "did" string not present. */ export function getDeviceIdValue(){ - const cookieValue = getCookieByName(cookieNames.DXDEV); - const cookieValueMatch = cookieValue.match("(?<=did=).*?(?=&)"); + // Sometimes these cookie contains more than the device ID. + const cookieValue = getCookieValueByName(cookieNames.DXDEV); + const cookieValuesSplit = cookieValue.split('='); + // If this is the only value, just use that. + if(cookieValuesSplit.length === 2){ + return cookieValuesSplit[1]; + } + + const cookieValueMatch = cookieValue.match("(?<=did=).*?(?=&)"); if(cookieValueMatch){ return cookieValueMatch[0]; } @@ -71,7 +78,7 @@ export function getDeviceIdValue(){ Gets value of sid cookie, returns empty string if not found. */ export function getSessionIdValue(){ - const cookieValue = getCookieByName(cookieNames.SESSION_ID); + const cookieValue = getCookieValueByName(cookieNames.SESSION_ID); if(cookieValue){ return cookieValue; @@ -84,7 +91,7 @@ export function getSessionIdValue(){ Gets value of skey cookie, returns 0 if not found. */ export function getSessionKeyValue(){ - const cookieValue = getCookieByName(cookieNames.SESSION_KEY); + const cookieValue = getCookieValueByName(cookieNames.SESSION_KEY); if(cookieValue){ return cookieValue; @@ -140,7 +147,7 @@ function getDomainWithoutSubdomain() { /* Gets cookie value by name, returns empty string if not found. */ -function getCookieByName(name) { +function getCookieValueByName(name) { const value = "; " + document.cookie; const parts = value.split("; " + name + "=");