How to save cookies in CefSharp

2019-02-16 20:59发布

问题:

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);

回答1:

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



回答2:

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;

        }
    }


标签: c# CefSharp