I'm facing an issue with 2 domains where performing an action on the first domain results in setting a cookie that should be accessible on both domains. However, when trying to read the value of this cookie on the second domain, it appears empty. Can anyone explain why?
Here's a snippet of code that retrieves the cookie value:
const getCookie = ClientFunction(() => {
const name = 'ConfigCookie';
const match = document.cookie.match(new RegExp(name + '=([^;]+)'));
let decodedValue;
if (match) decodedValue = decodeURIComponent(match[1]).replace(/%28/g, '(').replace(/%29/g, ')');
return JSON.parse(decodedValue || '');
})
Below is a test script (with sensitive data removed) that replicates the problem:
test('xyz', async t => {
await t
.navigateTo(FirstDomain)
.click(firstDomainSubmitButtonSelector)
const firstDomainCookie = await getCookie();
const firstDomainConsents = firstDomainCookie.consents;
await t
.expect(consents).eql({here the expected value});
await t
.navigateTo(SecondDomain)
const secondDomainCookie = await getCookie();
const secondDomainConsents = secondDomainCookie.consents;
console.log(secondDomainConsents)
})