Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share cookie data in chrome custom tabs android

We have an android app where we want to open a url.To avoid user re entering user name and password, we want to pass the session cookies. We can use webview inside our app to do this but we want to avoid webviews.

Another solution we found is using chrome custom tabs. As per the documentation https://developer.chrome.com/multidevice/android/customtabs chrome custom tabs supports:

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

I am trying the example from https://github.com/GoogleChrome/custom-tabs-client But i am not able to figure out how to pass the session data.

Can anyone help me by pointing to documentation or way to achieve this ?

like image 362
Pranay Airan Avatar asked Aug 28 '15 09:08

Pranay Airan


People also ask

Do Chrome Tabs share cookies?

Cookies are specific to websites. If you have multiple tabs open to various pages on the same site they'll share cookies. Tabs open to different websites don't have access to cookies used by another site regardless of whether it's open in another tab.

What is custom tab intent?

Chrome custom tabs give apps more control over their web experience, and make transitions between native and web content more seamless without having to resort to a WebView. Chrome custom tabs allow an app to customize how Chrome looks and feels. An app can change things like: Toolbar color.


1 Answers

The shared cookie jar means that the Custom Tab shares the cookie jar with Chrome. As of today, it is not possible to set a cookie from the application inside a Custom Tab.

On the other hand, you may want to check Smart Lock for Passwords, which enables automatic sign-in across applications and websites (and will work inside a Custom Tab)

like image 157
andreban Avatar answered Nov 09 '22 00:11

andreban