码迷,mamicode.com
首页 > Web开发 > 详细

使用 InternetGetCookieEx 获取webbrowser中的 cookie 包含 httponly

时间:2018-01-25 10:52:09      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:locate   internet   cookie   str   cookies   min   form   term   httponly   

namespace AliLoginForm
{
    public class MyIECookie
    {

        //[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
        //static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref int pcchCookieData, int dwFlags, IntPtr lpReserved);
        //取出Cookie,当登录后才能取    
        public static string GetCookieString(string url)
        {
            // Determine the size of the cookie      
            uint datasize = 256;
            StringBuilder cookieData = new StringBuilder((int)datasize);
            if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, IntPtr.Zero))
            {
                if (datasize < 0)
                    return null;
                // Allocate stringbuilder large enough to hold the cookie    
                cookieData = new StringBuilder((int)datasize);
                if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, IntPtr.Zero))
                    return null;
            }
            return cookieData.ToString();
        }

        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref System.UInt32 pcchCookieData, int dwFlags, IntPtr lpReserved);
    }
}

 

使用 InternetGetCookieEx 获取webbrowser中的 cookie 包含 httponly

标签:locate   internet   cookie   str   cookies   min   form   term   httponly   

原文地址:https://www.cnblogs.com/cxlater/p/8349784.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!