Get Cookie Issue on Logged Out Users

Hi guys,

We’re having an issue with the {{dc:cookie:get name=“isVet”}} condition on the front-end.

On desktop, it seemed to work as expected, but the behaviour was a bit inconsistent on mobile (debugging on iOS Safari). After some digging, we’re thinking it’s because the user was logged out of WordPress, as we got similar behaviour when testing on incognito. We can see that the cookie is there on dev tools, but for some reason this condition doesn’t kick in:

We have some Page JS that checks document.cookies, which is working as expected:
window.addEventListener(‘DOMContentLoaded’, () => {
// console.log(document.cookie);
if (!document.cookie.split(’;’).some(c => c.trim().startsWith(‘isVet=’))) {
if (window.location.hash !== ‘#access’) {
window.location.hash = ‘access’;
}
}
});

Weirdly, sometimes it worked when we added that console.log() statement above, but other times it didn’t, and we’re not sure why. Are there any known issues with dc:cookie:get, or any ideas of what could be causing this?

Thanks

(Edited post) Just digging into this a bit more - it seems that users who are not logged into WordPress aren’t seeing this issue, but logged out users are. Also, for more context, the cookie is set on a Cornerstone Form.

We’re wondering if maybe this is a bug?

Hello @RubberDuckers,

We would be happy to double check your site if we can log in. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

Sure thing

Hey @RubberDuckers,

I was wondering where you have set the cookie. I could not find where you have added the condition to get the cookie name as well.

You may have forgot to mention it.

Thanks.

The cookie is set via the Vet Form Modal component (found in Other Components - there is a CS form with an action to set it). On the For Vets page, the cookie condition is set on the component instance, and a couple other sections (Resources and News).