I have 2 WinForms, each with its own browser instance. Everything is working great but I cant seem to figure out how to clear the cookies for the chosen instance instead of globally.
To set the cache folder
var requestContextSettings1 = new RequestContextSettings
{
CachePath = System.IO.Path.GetFullPath("DesktopCache") // Path to the cache folder
};
var requestContext1 = new RequestContext(requestContextSettings1);
public void ClearBrowserCache()
{
var requestContext = Cef.GetGlobalRequestContext();
if (requestContext != null)
{
var cookieManager = requestContext.GetCookieManager(null);
if (cookieManager != null)
{
cookieManager.DeleteCookies("", "", new DeleteCookiesCallback());
}
}
}
I know the above code gets the global requestcontext, I am just giving an example of what does work globally.
Next I tried something like
var cookieManager = browser.GetCookieManager();
cookieManager.DeleteCookiesAsync();
I even tried deleting the cache folder. Deleting the cache folder didnt seem to clear the session/memory cookies.
Again, seemed to have cleared cookies for both instances. I know this is something simple I am missing. Any chance someone know what it is?
1
It seems to me you would have to load each form each in its own AppDomain and initialize each instance with different cache directories. Then you can clear each instance’s cache separately.
SSoper97470 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2