设置cookie
var cook = Cef.GetGlobalCookieManager();
cook.SetCookieAsync(url, new CefSharp.Cookie
{
Domain = "",
Name = "",
Value = "",
});
读取cookie
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
CookieVisitor visitor = new CookieVisitor();
visitor.SendCookie += visitor_SendCookie;
ICookieManager cookieManager = browser.GetCookieManager();
cookieManager.VisitAllCookies(visitor);
}
private void visitor_SendCookie(CefSharp.Cookie obj)
{
//obj.Domain.TrimStart('.') + "^" +
string cookies = obj.Name + ":" + obj.Value + ";";
}
public class CookieVisitor : CefSharp.ICookieVisitor
{
public event Action<CefSharp.Cookie> SendCookie;
public void Dispose()
{
}
public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie)
{
deleteCookie = false;
if (SendCookie != null)
{
SendCookie(cookie);
}
return true;
}
}
版权声明:本文为Little_Code原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。