How can I clear all cookies at the time?

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

How can I clear all cookies at the time?

Postby VictorBozhuk » Mon Mar 15, 2021 6:30 am

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.
VictorBozhuk
Newbie
 
Posts: 1
Joined: Wed Jan 13, 2021 8:14 am

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

Postby fddima » Mon Mar 15, 2021 6:38 am

1. You can call `CefCookieManager::DeleteCookies("", "")` to delete all cookies.

2. Setting `delete` in CefCookieVisitor is a valid option, and this should work.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 14 guests