c# 设置内存中的cookies
1: [DllImport("wininet.dll", SetLastError = true)]
2: public static extern bool InternetSetCookieEx(
3: string url,
4: string cookieName,
5: StringBuilder cookieData,
6: Int32 dwFlags,
7: IntPtr lpReserved);
1: public static void SetCookieForBrowserControl(CookieContainer cc, Uri uri)
2: {
3: String hostName = uri.Scheme + Uri.SchemeDelimiter + uri.Host;
4: Uri hostUri = new Uri(hostName);
5: foreach (Cookie cookie in cc.GetCookies(hostUri))
6: {
7: InternetSetCookieEx(hostName, cookie.Name, new StringBuilder(cookie.Value), 0, IntPtr.Zero);
8: }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步