Search code examples
androidkotlinandroid-studioandroidxchrome-custom-tabs

Turn off cookie sharing in Chrome custom tabs


Is there any way we can turn off cookie sharing in Android custom tabs?

I am implementing a login functionality via custom tabs.

Assume the user has logged in via custom tab;

Once the user is logged out of the APP and again tries to log in via custom tab, the user is navigaged to the home page of the website (Since the user log in happened previously).

If the cookies are not shared and the browser instance doesn't contain any previous data, the user wouldn't be considered as logged in. Does custom tab currently support that?


Solution

  • Unfortunately you can't do this programmatically. I've tried the same recently, spending hours to find out if it's possible or not but it seems it's not. In the Chrome documentation it explicitly mentions that cookies are shared:

    Shared cookie jar and permissions model so users don't have to sign-in to sites they are already connected to, or re-grant permissions they have already granted.

    By browsing the Custom Tabs package summary and its classes, there is no word about cookies at all.

    If you own or control the behavior of the web page, you can bypass this by adding a query parameter to force open the login page but if it's a 3rd party web page, unfortunately you are out of luck.