Currently I'm setting the cache path as follows:
CefSettings settings = new CefSettings();
settings.CachePath = mycachePath;
Cef.Initialize(settings);
var browser = new ChromiumWebBrowser(myUrl);
The above works.
However, I need to login to a website with 2 different accounts simultaneously but it uses the same cookie container. So if I login with one account and then the other, the first account is overridden.
Is it possible to have a have a cache path per browser?
Or is there a better way to handle this situation?
It looks like you're using CefSharp? If so, looking through the code, it seems that you want to create the browser with an empty CachePath:
/// <summary>
/// Returns the cache path for this object. If empty an "incognito mode"
/// in-memory cache is being used.
/// </summary>
string CachePath { get; }
Looking at their sample (I'm assuming windowless), this looks like it'll get roughly what you want:
var browserSettings = new BrowserSettings();
var requestContextSettings = new RequestContextSettings { CachePath = "" };
using(var requestContext = new RequestContext(requestContextSettings))
using (var browser = new ChromiumWebBrowser(TestUrl, browserSettings, requestContext))
{
...
}
来源:https://stackoverflow.com/questions/34549565/separate-cache-per-browser