Page 1 of 1

How can I clear all cookies at the time?

PostPosted: Mon Mar 15, 2021 6:30 am
by VictorBozhuk
I have such an implementation of CefCookieVisitor.
Code: Select all
    internal class CookieVisitor : CefCookieVisitor
    {
        public static List<Cookie> GetCookies()
        {
            return _cookies.Distinct().ToList();
        }
        private static readonly ConcurrentBag<Cookie> _cookies = new ConcurrentBag<Cookie>();

        public static event Action<CefCookie> OnEachCookieAdd;

        protected override bool Visit(CefCookie cookie, int count, int total, out bool delete)
        {
            OnEachCookieAdd?.Invoke(cookie);
            _cookies.Add(new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain));

            delete = false;
            return true;
        }
    }


I would like to clear all cookies when I need. Is there any option to do it? I tried disposing of CefCookieVisitor, I tried setting the delete parameter in the Visit method but all of them don't really seem to solve the problem.

Re: How can I clear all cookies at the time?

PostPosted: Mon Mar 15, 2021 6:38 am
by fddima
1. You can call `CefCookieManager::DeleteCookies("", "")` to delete all cookies.

2. Setting `delete` in CefCookieVisitor is a valid option, and this should work.