Having an issue where some of our cookies are being arbitrarily deleted in Facebooks In-App browser, and I cannot figure out what is removing them. One of the cookies is our session cookie, so not having that renders the site pretty much unusable in the app. Is there some way in Chrome's remote debugging tools I can put a listener on the cookie to figure out what is removing it so I can fix the problem? The website works as expected in every other web browser except the Facebook In-App browser and it's a very frustrating thing to troubleshoot and fix.
-
Your question makes no sense - You talk about Facebooks In-App browser but then talk about debugging in Chrome?– davidgoCommented Oct 9 at 22:18
-
1It's unlikely to be arbitrary. Have you tried writing the cookies to screen to see which work and which don't, and seeing if there's any obvious difference in how you are generating them? (There are tools for what you want, but I've personally never used any - see stackoverflow.com/questions/27199489/…)– RichardBCommented Oct 9 at 22:51
1 Answer
To understand when and under what conditions cookies are being deleted, you can use simple JavaScript to check for the presence of a cookie at regular intervals.
Something like this:
function checkCookie(cookieName) {
const cookieExists = document.cookie.split(';').some(cookie => cookie.trim().startsWith(`${cookieName}=`));
console.log(`Cookie "${cookieName}" is ${cookieExists ? 'present' : 'absent'}`);
}
// Check for the presence of the cookie every 5 seconds
setInterval(() => checkCookie('sessionCookie'), 5000);
Also, as an option, the in-app browser in FB might be restricting cookies for security reasons. Settings like SameSite, Secure, HttpOnly might be affected.
Check and adjust the configuration if needed.
If it's not too much trouble, let me know what went wrong.