Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Extrac SameSite=Strict cookie from Webview or URL

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" ?

like image 556
Arslan Avatar asked Nov 25 '16 06:11

Arslan


2 Answers

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

like image 97
David Alan Hjelle Avatar answered Oct 17 '22 15:10

David Alan Hjelle


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.

like image 45
hexagod Avatar answered Oct 17 '22 15:10

hexagod