Question Regarding Cookies and Multiple JCEF Instances
Posted:
Tue Sep 04, 2018 1:51 pm
by joxrox
Hello,
I am trying to create a program that uses multiple JCEF instances, each with their own unique cookie storage, to automate tasks on sites. So far, I have modified and built JCEF on so that the browsers run headlessly, but now I need each instance to have it's own cookie storage. Is this possible with the current builds of JCEF or will I need to make more modifications to the source code? If it is possible, can anyone give me a snippet of code that demonstrates how to do this?
Best regards,
Joe
Re: Question Regarding Cookies and Multiple JCEF Instances
Posted:
Tue Sep 04, 2018 4:09 pm
by Czarek
In CEF to implement unique cookie managers you have to provide a unique CefRequestContext when creating browser and implement CefRequestHandler::GetCookieManager.
Re: Question Regarding Cookies and Multiple JCEF Instances
Posted:
Tue Sep 04, 2018 7:53 pm
by joxrox
Czarek wrote:In CEF to implement unique cookie managers you have to provide a unique CefRequestContext when creating browser and implement CefRequestHandler::GetCookieManager.
Thanks for your reply. I saw that in another forum post but I am having trouble understanding how to do this in Java since I am using JCEF. Do you think that I need to make changes to source code or can it be done in Java?
Re: Question Regarding Cookies and Multiple JCEF Instances
Posted:
Wed Sep 05, 2018 12:04 am
by Czarek
Re: Question Regarding Cookies and Multiple JCEF Instances
Posted:
Sun Oct 14, 2018 3:39 am
by JohnnyTheHun
You need something like this
- Code: Select all
class MyReqContextHandler implements CefRequestContextHandler {
CefCookieManager cookieManager = null;
...
MyReqContextHandler() {
....
cookieManager = CefCookieManager.createManager(cookiePath, false);
....
}
public CefCookieManager getCookieManager() {
return cookieManager;
}
}
MyReqContextHandler contextHandler = new MyReqContextHandler();
CefRequestContext requestContext = CefRequestContext.createContext(contextHandler);
CefBrowser browser_ = client_.createBrowser(url, useOSR, isTransparent,requestContext);
Re: Question Regarding Cookies and Multiple JCEF Instances
Posted:
Sun Feb 02, 2020 2:52 am
by JohnnyTheHun
this no longer applies for newer versions of CEF. CefCookieManager.createManager was removed.