google-chromecookieschrome-custom-tabsandroid-customtabs

Chrome custom tabs cookies, storage APIs and service worker


I tried to lookup many answers from stackoverflow but couldnt find anything specific to this, I am implementing payment app and I want to display custom-tab in my app to record user visit by storing user-id, either by setting a cookie or using localstorage or by installing a service worker for the domain that custom tabs opens.

  1. Can a https page loaded in custom-tab write cookies that are also available when visiting the same page from Chrome?
  2. Is localstorage API available for my domain in custom-tab? if yes, is stored value available from Chrome?
  3. Is installing service worker allowed from Custom-tab? So I have access to S/W from Chrome browser?

If none of this possible, how could I record the visit from custom-tab and have it available in Chrome when user opens the domain from chrome browser?

Thanks in advance


Solution

    1. Chrome Custom Tabs uses the same Cookie jar as Chrome. So, if a Cookie is created when a user accesses the page from a Custom Tab and Chrome is the Custom Tabs provider, it is also available when the user goes to the same domain from Chrome (outside Custom Tabs).
    2. Same as above.
    3. Yes, it is possible to install a service-worker from a Chrome Custom Tab.

    You can check all the above by opening the URL that adds the cookie, install the service-worker or writes to the local store inside a Custom Tab, setup the device for debugging, connecting it to your computer and navigating to chrome://inspect/#devices in Chrome. Then choose the device and inspect the cookies, local storage, service-workers, etc.