protected void CleanupCookieList() { try { string S = ""; CookieList LCookieList; if (_Cookies != null) { lock (_Cookies.GetCookieListByDomain()) { if (_Cookies.GetCookieListByDomain() != null) { if (_Cookies.GetCookieListByDomain().Count > 0) { for (int i = 0; i < _Cookies.GetCookieListByDomain().Count; i++) { LCookieList = (CookieList)_Cookies.GetCookieListByDomain().Values[i]; for (int j = LCookieList.Count - 1; j >= 0; j--) { S = LCookieList.Cookie(j).Expires; if (S.Length > 0 && Http.GmtToLocalDateTime(S) < DateTime.Now) { LCookieList.RemoveAt(j); } } } } } } } } catch { } }
public string GenerateCookieList(URI AUri, bool SecureConnection) { string S = ""; CookieList LCookieList; SortedList <string, string> LResultList; CleanupCookieList(); lock (_Cookies.GetCookieListByDomain()) { if (_Cookies.GetCookieListByDomain().Count > 0) { LResultList = new SortedList <string, string>(); for (int i = 0; i < _Cookies.GetCookieListByDomain().Count; i++) { if (_Cookies.GetCookieListByDomain().IndexOfKey(AUri.Host) > 0) { LCookieList = (CookieList)_Cookies.GetCookieListByDomain()[AUri.Host]; for (int j = 0; j < LCookieList.Count; i++) { if (LCookieList.Cookie(j).Path.IndexOf(AUri.Path) == 0) { if ((LCookieList.Cookie(j).Secure || SecureConnection) && (LCookieList.Cookie(j).Value != "")) { LResultList.Add(LCookieList.Cookie(j).CookieName, LCookieList.Cookie(j).Value); } } } } } for (int i = LResultList.Count; i > 0; i--) { if (S.Length > 0) { S += "; "; } S += LResultList.Keys[i] + "=" + LResultList.Values[i]; } } } return(S); }