1

I am very curious if there is a possibility in CEF Sharp , somehow to isolate each instance of browser from other instances.

I am creating 4 instances of browser. Logging in on of the instances , immediately 3 other instances become logged in as well.

Is it possible to achieve somehow in Current version that we got from Nuget ?

alonso miuyh
  • 13
  • 1
  • 4

2 Answers2

9

As of revision 2040, CEF now adds support for complete isolation of storage and permissions (cache, cookies, localStorage, access grants, etc) on a request context basis. This is also now in CEFSharp.

To make sure that no sessions overlap between multiple instances, simply create a new RequestContextSettings object, set PersistSessionCookies and/or PersistUserPreferences to false, and assign it to your browser while creating a new RequestContext - I am not sure if setting them to false is completely necessary for multiple instances, maybe someone else can give some info on that.

//usually ChromiumWebBrowser setup goes above this

RequestContextSettings requestContextSettings = new RequestContextSettings();

requestContextSettings.PersistSessionCookies = false;
requestContextSettings.PersistUserPreferences = false;

webBrowser.RequestContext = new RequestContext(requestContextSettings);

This had been giving me headaches for a while and this appears to finally solve that issue.

Tobi Schweiger
  • 111
  • 1
  • 6
-2

Just use this code, its working for me.

public MainWindow()
    {
        CefSharp.CefSettings settings = new CefSharp.CefSettings();
        settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\CEF"; 
       CefSharp.Cef.Initialize(settings);

        InitializeComponent();
        browser = new ChromiumWebBrowser("https://google.com/");
        browser.BrowserSettings.ApplicationCache = CefSharp.CefState.Disabled;

    }
  • 3
    Because he literally asked to "isolate each browser instance from others" but the answer you suggessted is complete opposite - setting custom folder for ALL instances in general. – Roni Tovi May 28 '19 at 09:28