15

I'm new to CefSharp. Last week i build my first little program with CefSharp in C#. It's a split screen program. In one split i loaded Tweetdeck. It works fine, but Tweetdeck doesn't store cookies. Every time i start the program, i must login. Is there a way to save the cookies?

var browser1 = new CefSharp.WinForms.ChromiumWebBrowser("https://tweetdeck.twitter.com/")
        {
            Dock = DockStyle.Fill,
        };
splitContainer1.Panel1.Controls.Add(browser1);
NVO
  • 2,566
  • 5
  • 27
  • 57

2 Answers2

20

Set CefSettings.CachePath directory. Settings are passed to Cef.Initialize().

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56
18

just on how to use it.

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

            InitializeComponent();
            //webcontrol.BrowserSettings.ApplicationCache = CefSharp.CefState.Enabled;

        }
    }
shyam_
  • 2,370
  • 1
  • 27
  • 50
  • 1
    You should ideally use a separate folder for cache directory – amaitland Jan 28 '17 at 01:08
  • 1
    I have suggested an edit as using the chrome cache folder is problematic at best. You would likely have problems running them at the same time and when Google updates to a newer version it will potentially break if you have a version mismatch with CefSharp being older. – amaitland Jan 31 '17 at 05:20
  • 2
    Now this class is in a different namespace: `CefSharp.WinForms.CefSettings` – andrew.fox Apr 03 '21 at 13:53