Home » Android » Android – Extrac SameSite=Strict cookie from Webview or URL

Android – Extrac SameSite=Strict cookie from Webview or URL

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m using the following code within the onPageFinished() of a WebViewClient to read the cookies . But some cookies are set “SameSite=Strict”, which I cannot get using the method below:

 @Override
 public void onPageFinished(WebView view, String url){
     String cookies = CookieManager.getInstance().getCookie(url);
     Log.d(TAG, "All the cookies in a string:" + cookies);
 }

Can anybody tell me how to get the cookies which are set “SameSite=Strict” ?

How to&Answers:

It is officially a bug in Chromium and needs to be (hopefully will be) fixed there.

Answer:

This was fixed in WebView 72. If you’re not getting the SameSite Lax or Strict cookies, you need to update the System WebView implementation to any version >= 72

David’s post has a link to the bug and I have just confirmed after updating from version 70 to 80 that the CookieManager instance is now getting ALL cookies.