zoukankan      html  css  js  c++  java
  • c#后的完整cookie

    http://www.cnblogs.com/top5/archive/2010/04/11/1709457.html

    c#设置 webbrowser的请求cookie,可以通过fiddler分析cookie是否设置成功,记得带http://

    http://stackoverflow.com/questions/8232419/why-this-code-using-internetsetcookie-to-set-cookies-at-a-webbroser-control-is-n

    http://blog.csdn.net/attilax/article/details/8595036

     public static class CookieReader
        {
            /// <summary>
            /// Enables the retrieval of cookies that are marked as "HTTPOnly". 
            /// Do not use this flag if you expose a scriptable interface, 
            /// because this has security implications. It is imperative that 
            /// you use this flag only if you can guarantee that you will never 
            /// expose the cookie to third-party code by way of an 
            /// extensibility mechanism you provide. 
            /// Version:  Requires Internet Explorer 8.0 or later.
            /// </summary>
            private const int INTERNET_COOKIE_HTTPONLY = 0x00002000;
    
            [DllImport("wininet.dll", SetLastError = true)]
            private static extern bool InternetGetCookieEx(
                string url,
                string cookieName,
                StringBuilder cookieData,
                ref int size,
                int flags,
                IntPtr pReserved);
    
            /// <summary>
            /// Returns cookie contents as a string    *****可用*****
            /// </summary>
            /// <param name="url"></param>
            /// <returns></returns>
            public static string GetCookie(string url)
            {
                int size = 512;
                StringBuilder sb = new StringBuilder(size);
                if (!InternetGetCookieEx(url, null, sb, ref size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero))
                {
                    if (size < 0)
                    {
                        return null;
                    }
                    sb = new StringBuilder(size);
                    if (!InternetGetCookieEx(url, null, sb, ref size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero))
                    {
                        return null;
                    }
                }
                return sb.ToString();
            }
    
        }
  • 相关阅读:
    OleDbConnection SqlConnection DB2Connection 区别
    网站软件FTP下载
    总结方法论
    面向对象的三大基石(封装,继承和复合,多态)
    wkhtmltopdf中文参数
    HTTP协议的8种请求类型介绍
    枚举操作笔记
    自写任务调度模型
    数据库操作类
    LoadRunner录制后无法自动生成脚本
  • 原文地址:https://www.cnblogs.com/norm/p/6404670.html
Copyright © 2011-2022 走看看