//See also overload for HttpCookieCollection public static string CookieCollectionAsString(System.Net.CookieCollection cookies, string sComment, LoggingOutputLevel level) { StringBuilder sb = new StringBuilder(); // string sRet = ""; if (!String.IsNullOrEmpty(sComment)) { sb.Append(sComment + Environment.NewLine); } sb.AppendFormat("Cookies collection. Count={0}\n", cookies.Count.ToString()); // Print the properties of each cookie. foreach (Cookie cookie1 in cookies) { if (level > LoggingOutputLevel.Brief) { sb.AppendFormat("{0} = {1}\n", cookie1.Name, cookie1.Value); sb.AppendFormat("Domain: {0}\n", cookie1.Domain); sb.AppendFormat("Path: {0}\n", cookie1.Path); sb.AppendFormat("Port: {0}\n", cookie1.Port); sb.AppendFormat("Secure: {0}\n", cookie1.Secure); sb.AppendFormat("When issued: {0}\n", cookie1.TimeStamp); sb.AppendFormat("Expires: {0} (expired? {1})", cookie1.Expires, cookie1.Expired); sb.AppendFormat("Don't save: {0}\n", cookie1.Discard); sb.AppendFormat("Comment: {0}\n", cookie1.Comment); sb.AppendFormat("Uri for comments: {0}\n", cookie1.CommentUri); sb.AppendFormat("Version: RFC {0}\n", cookie1.Version == 1 ? "2109" : "2965"); } // Show the string representation of the cookie. sb.AppendFormat("String: {0}", cookie1.ToString()); } return(sb.ToString()); }
public static void PrintCookies(CookieCollection cookies, string sComment, LoggingOutputLevel level) { Debug.WriteLine(TraceOutputHelper.CookieCollectionAsString(cookies, sComment, level)); }