CefSharp 如何存储 cookie

CefSharp how to store cookies

我无法将 cookie 保存在 CefSharp 中。

这是我尝试过的:

        CefSettings settings = new CefSettings();
        string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        Cef.Initialize(new CefSettings());
        settings.RemoteDebuggingPort = 8088;
        settings.CachePath = path;

我使用桌面只是为了测试它,但我也尝试了其他桌面。

这是其他人得到的解决方案,但我无法让它工作: 设置 CefSettings.CachePath 目录。设置传递给 Cef.Initialize()。答案来自 .

评论后我试过这个:

在初始化部分我把这个

        CefSettings settings = new CefSettings();
        string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        settings.RemoteDebuggingPort = 8088;
        settings.CachePath = path;
        Cef.Initialize(new CefSettings());

private void Form1_Load(object sender, EventArgs e)
{
        SearchBox.Text = "http://www.google.com/";
        chrome = new ChromiumWebBrowser(SearchBox.Text);
        this.MainBrowser.Controls.Add(chrome);
        chrome.Dock = DockStyle.Fill;
        chrome.AddressChanged += Chrome_AddressChanged;
        private void InitializeChromium()
    {
        CefSettings settings = new CefSettings();
        string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        settings.RemoteDebuggingPort = 8080;
        settings.CachePath = path;

        //Initialize Cef with the provided settings
        Cef.Initialize(settings);


        //Create a browser component
        chrome = new ChromiumWebBrowser(SearchBox.Text);

        //Add he browser to the form
        this.MainBrowser.Controls.Add(chrome);
        //Make the browser fill the form
        chrome.Dock = DockStyle.Fill;
    }