- 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.