Questions tagged [cookiemanager]

java.net.CookieManager This class provides a concrete implementation of CookieHandler. It separates the storage of cookies from the policy which decides to accept or deny cookies.

This class provides a concrete implementation of CookieHandler. It separates the storage of cookies from the policy which decides to accept or deny cookies. The constructor can have two arguments: a CookieStore and a CookiePolicy. The former is in charge of cookie storage and the latter makes decision on acceptance/rejection. CookieHandler is in the center of cookie management. User can make use of CookieHandler.setDefault to set a CookieManager as the default one used. CookieManager.put uses CookiePolicy.shouldAccept to decide whether to put some cookies into a cookie store. Three built-in CookiePolicy is defined: ACCEPT_ALL, ACCEPT_NONE and ACCEPT_ORIGINAL_SERVER. Users can also customize the policy by implementing CookiePolicy. Any accepted HTTP cookie is stored in CookieStore and users can also have their own implementation. Up to now, Only add(URI, HttpCookie) and get(URI) are used by CookieManager. Other methods in this class may probably be used in a more complicated implementation. There are many ways to customize user's own HTTP cookie management: First, call CookieHandler.setDefault to set a new CookieHandler implementation. Second, call CookieHandler.getDefault to use CookieManager. The CookiePolicy and CookieStore used are customized. Third, use the customized CookiePolicy and the CookieStore. This implementation conforms to RFC 2965 section 3.3.

56 questions
29
votes
1 answer

Should HttpURLConnection with CookieManager automatically handle session cookies?

I have a Java application (JDK 1.7.0_13) and am using java.net.HttpURLConnection to connect to some servlet based services that do session management. I am trying to figure out how to use java.net.CookieManager to track session cookies. Reading…
Chuck
  • 1,788
  • 2
  • 15
  • 28
23
votes
4 answers

Retrofit - Too many follow-up requests: 21

I'm using retrofit to make requests. I've got following error: java.net.ProtocolException: Too many follow-up requests: 21 The code is like below: private OkHttpClient httpClient; private CookieManager cookieManager; public S…
Marcin Bortel
  • 902
  • 1
  • 9
  • 26
12
votes
1 answer

how to remove specific cookie value?

In my app there are facebook and twitter login using browser and after login it stores cookies automatically. i have to logout facebook that will be happen to remove facebook cookies value but i don't know how to remove particular cookies. if i…
Archana
  • 509
  • 2
  • 6
  • 20
12
votes
3 answers

Cookie manager causing fatal signal 11

My app silently crashes (no force close popup) when i try to set a cookie on the cookiemanager. mHttpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false); HttpGet http_get = new HttpGet(url); HttpResponse response =…
user2128112
  • 299
  • 4
  • 13
6
votes
2 answers

MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US

I am getting, Caused by java.lang.InternalError: java.util.MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US in my application from firebase crash report. Other details Manufacturer:…
q126y
  • 1,595
  • 3
  • 15
  • 36
5
votes
1 answer

Manually set a cookie in default cookiestore and using it in okhttp requests

In my android application, I am migrating to okhttp and need to setup the PHPSESSID manually for logged-in users in the default cookieStore, so that they don't get logged out. I am manually setting the cookie using the following…
Udbhav
  • 220
  • 3
  • 9
5
votes
1 answer

Android CookieManager

I have an application that makes several web calls in order to get authenticated after which a JSON is returned. My web calls are to an https server and I am using HTTPURlConnection. I need to store the session in a cookie, after researching around,…
AdamM
  • 4,205
  • 5
  • 45
  • 89
3
votes
0 answers

Do I need to flush after setCookie in CookieManager?

I have a code that writes the cookies from okHttp to CookieManager as below. @Override public void saveFromResponse(HttpUrl url, List cookies) { CookieManager webviewCookieManager = CookieManager.getInstance(); String urlString =…
Elye
  • 30,821
  • 26
  • 115
  • 272
3
votes
0 answers

How to use CookieManager with HttpURLConnection correctly?

I'm developing a small program that performs login via HttpUrlConnection in a session-based screen, save the cookies and go to another page using the saved cookies. My code looks like this: public class LoginConnection { private final String…
3
votes
2 answers

CEFSharp separate CookieManage

I am trying to create separate user sessions per chromium browser instance but cannot find any relevant examples as to how. The purpose is to store cookies separately per browser instance. Could anyone point me in the right direction? I would post…
astralmaster
  • 1,992
  • 11
  • 45
  • 76
3
votes
1 answer

How to keep session with HttpUrlConnection?

I'm using HttpUrlConnection to perform some http request and I need to keep a session alive. I read the doc which just say to add CookieManager cookieManager = new CookieManager(); CookieHandler.setDefault(cookieManager); but it does not say…
jul
  • 33,288
  • 64
  • 178
  • 299
3
votes
2 answers

android - share session between two webviews?

first of all, can someone please explain how does CookieManager.getInstance() work? I don't really get how I can get the session from webview? Lets say if I have this CookieSyncManager.createInstance(WebviewPage.this); CookieManager cookieManager =…
user1865027
  • 2,915
  • 4
  • 26
  • 56
2
votes
1 answer

HttpURLConnection with a non system-wide CookieHandler

I have a web application that makes HTTP requests using HttpURLConnection. I need it to handle cookies. I know that it's easily done by adding just one line of code, something like CookieHandler.setDefault(new CookieManager(null,…
John29
  • 2,830
  • 2
  • 27
  • 48
2
votes
1 answer

Creating a new cookie in Android

I want to create a new Cookie in Android. When I do: Cookie testCookie = new Cookie(); I get an error saying, "Cannot instantiate the type Cookie". All I want to do is create a new cookie and stick it into a cookie store (uses…
Jessie A. Morris
  • 2,169
  • 20
  • 22
2
votes
0 answers

espresso times out on CookieManager.getInstance().setCookie(name, value)

I'm writing an espresso test for a login activity that sets cookies: CookieManager.getInstance().setCookie(name, value) But the test hangs at the above code then times out. Looking into the setCookie code I think it calls some native jni method. I…
Bing Qiao
  • 321
  • 1
  • 4
  • 10
1
2 3 4