设置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;
}
}
今天的文章C# Cefsharp 获取cookie 和设置cookie分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/32154.html