/// <summary> /// get list of chrome cookies /// </summary> /// <returns></returns> public static List<CookieData> GetChromeCookies() { var cookies = new List<CookieData>(); if (GetCHromePath() != "") { using (var conn = new SQLiteConnection("Data Source=" + GetCHromePath())) { using (SQLiteCommand cmd = conn.CreateCommand()) { cmd.CommandText = "select * from cookies"; // where host like '%" + host + "%';"; try { conn.Open(); using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { //for (int i = 0; i < reader.FieldCount; i++) { var data = new CookieData { ID = reader["creation_utc"].ToString(), Name = reader["name"].ToString(), Host = reader["host_key"].ToString(), Path = reader["path"].ToString() }; cookies.Add(data); } } } } catch (Exception) { } finally { conn.Close(); } } } } return cookies; }
/// <summary> /// get list of firefox cookies /// </summary> /// <returns></returns> public static List<CookieData> GetCookies() { List<CookieData> cookies = new List<CookieData>(); if (!string.IsNullOrEmpty(GetFFCookiePath())) { using (var conn = new SQLiteConnection("Data Source=" + GetFFCookiePath())) { using (SQLiteCommand cmd = conn.CreateCommand()) { cmd.CommandText = "select * from moz_cookies"; try { conn.Open(); using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { CookieData data = new CookieData { ID = reader["id"].ToString(), Name = reader["name"].ToString(), Host = reader["host"].ToString(), Path = reader["path"].ToString() }; cookies.Add(data); } } } finally { cmd.Dispose(); conn.Close(); } } } } return cookies; }