How to save cookies in CefSharp
Asked Answered
K

2

16

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);
Kaiserdom answered 9/2, 2015 at 21:12 Comment(0)
M
21

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

Mancilla answered 9/2, 2015 at 21:54 Comment(2)
can you add more more details how to use itReify
@Reify Example code here: github.com/cefsharp/CefSharp/blob/…Mancilla
R
20

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;

        }
    }
Reify answered 27/1, 2017 at 23:48 Comment(3)
You should ideally use a separate folder for cache directoryNonflammable
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.Nonflammable
Now this class is in a different namespace: CefSharp.WinForms.CefSettingsArchlute

© 2022 - 2024 — McMap. All rights reserved.