android-cookiemanager

CookieManager.getCookie() always returns null (Version <= API 28 (Pie))

徘徊边缘 提交于 2021-01-28 08:08:17
问题 I use a standard android.webkit.Webview in a Java-Based native android app. Inside the Webview the User logs into a webapp. After successful login the webapp stores a cookie with the access token. I want to access this cookie. The cookie has the following characteristics: HTTPS Url Structure like: https://api.example.com httpOnly Flag Secure Flag When on Android API Level 29 or API Level 30, calling CookieManager.getCookie("https://api.example.com") works like expected and returns a String

How to persist webview cookies between app executions?

点点圈 提交于 2020-05-14 05:28:12
问题 It is possible to achieve this currently in Android? I only can find deprecated questions about old methods (CookieSynchManager) which not seems to work for this actually. It is possible to achieve it? can't find anything also on the android developers guide. Thank you 回答1: Having the same problem...I solved reading the doc here: https://developer.android.com/reference/android/webkit/CookieSyncManager For future readers: to force the Cookie sync process you can manually call the flush()

How to persist webview cookies between app executions?

夙愿已清 提交于 2020-05-14 05:27:10
问题 It is possible to achieve this currently in Android? I only can find deprecated questions about old methods (CookieSynchManager) which not seems to work for this actually. It is possible to achieve it? can't find anything also on the android developers guide. Thank you 回答1: Having the same problem...I solved reading the doc here: https://developer.android.com/reference/android/webkit/CookieSyncManager For future readers: to force the Cookie sync process you can manually call the flush()

Xamarin Android CookieManager doesn't store all cookies

江枫思渺然 提交于 2020-03-23 12:33:26
问题 I am using Android Web View in my Xamarin Project to perform third party authentication. Once the login is successful I need to extract the authentication cookies. This cookies I am storing in persistent storage and then I am using them for passing to subsequent requests. For example: Android App >(opens) webview > Loads (idp provider) url > User provides credentials and saml request is sent to my backend server > backend server validates saml and returns authentication cookies. It returns

Android webview( webkit.CookieManager) neglecting cookie attributes like ;expires

拈花ヽ惹草 提交于 2020-01-14 05:24:48
问题 Set-Cookie: oauth=xyz; domain=tyxbv; path=/; expires=Tue, 27-Oct-2020 17:16:00 GMT; secure; HttpOnly This is the cookie which i am getting from server when my webivew hits the url. But when I try to get the cookie details from the webview using getCookie("url which sets the cookie") i get oauth = xyz The other cookie attributes are not stored in the cookie store. I am unable to solve the above. I need other attributes also like path, expires. etc I am setting accept third party cookies true

Android, how to get a cookie from URL via HttpClient()?

六眼飞鱼酱① 提交于 2019-12-23 02:26:29
问题 I have a login activity and I have to create a post request for my website to login the user into my mobile app. To create post requests on my website I need the csrf cookie as parameter, it means I have first to get the cookie from my URL and after create my post request with the csrf value. Here is my code: HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://192.168.178.163:8080/login/"); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1

Android WebView get raw cookie information

不想你离开。 提交于 2019-12-13 12:30:43
问题 I try to get cookie information with CookieManager in Android WebView. However, all it does is providing a key value pair of cookies, no additional information. I also tried this post and use connection.getHeaderFields.get("Set-Cookie"); to get all cookies received from server. But from what I can tell, I don't see all cookies that I am supposed to receive from server. This can also be found by some cookies in CookieManger receive a new value but not show in Set-Cookie field. Ideally, I would

NullPointerException in CookieSyncManager.createInstance in AsyncTask

人盡茶涼 提交于 2019-12-13 05:50:02
问题 I have a class that extends from AysncTask . Inside the doInBackground method I want to update the cookies, so I have: CookieSyncManager.createInstance(context); // <<<<<<<<<<<<<<<<<< CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie(cookie.getDomain(), cookieString); CookieSyncManager.getInstance().sync(); But I get java.lang.NullPointerException in the first line. So, the question is: Why could be causing this ? Do I need to create it in another activity,

Impossible to update/remove specific cookie for android webview

天涯浪子 提交于 2019-12-13 03:22:46
问题 I am trying to delete a specific cookie for a domain and seems impossible. In a web view in onPageFinished I can see the cookie and the relevant URL. I am using the following code to delete the cookie: CookieManager cm = CookieManager.getInstance(); final String url = "https://server.com/foo/index.html?bar=1"; // this is the URL is see in the `onPageFinished` String cookiesString = cm.getCookie(url); String [] cookies = cookiesString.split(";"); for(String cookie:cookies) { String[]

CookieManager.removeExpiredCookie crashes on Android 4.1.2

孤者浪人 提交于 2019-12-13 02:24:04
问题 The following code crashes with the included thread dump on Android 4.1.2 (on a Sprint Note II). CookieManager.getInstance().removeExpiredCookie() Dump: 12-12 13:45:35.484 1551-2908/com.example.myapp W/dalvikvm﹕ Invalid indirect reference 0x4276f3d8 in decodeIndirectRef 12-12 13:45:35.484 1551-2908/com.example.myapp E/dalvikvm﹕ VM aborting 12-12 13:45:35.484 1551-2908/com.example.myapp A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 2908 (AsyncTask #2) 12-12 13:45:35.584