Android reading cookies

倖福魔咒の 提交于 2019-11-30 05:44:34

问题


Hey, how can I read a value of a cookie?

Example:

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

This will give me a string which has to be parsed with split on ';' and '='. Is there a "cookie string reader" or smth? Is there any other way of reading the value of only one particular cookie in the webview?

Thx!


回答1:


Well, I suggest that you parse the string into an Array yourself. That would then be something along these lines in standard Java:

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

Now you have an Array of name - value pairs, which you can further parse and then store.



来源:https://stackoverflow.com/questions/5840966/android-reading-cookies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!