Cookies for Android

Hey, how can I read the cookie value?

Example:

String cs = CookieManager.getInstance().getCookie(); System.out.println("Cookies string: "+cs); 

This will give me the string that needs to be parsed using split on ';' and '='. Is there a "cookie line reader" or smth? Is there any other way to read the value of only one specific cookie in a webview?

thanks!

+6
source share
1 answer

Well, I suggest that you yourself parse the string into an array. Then it will be something similar in standard Java:

 String[] x = Pattern.compile(";").split(CookieManager.getInstance().getCookie()); 

Now you have a couple of pairs of names and values ​​that you can further analyze and then save.

+9
source

Source: https://habr.com/ru/post/887005/


All Articles