CookieJar ICookieRetriever.GetCookies(string url)
        {
            if (driver == null)
            {
                throw new Exception();
            }

            IJavaScriptExecutor js = driver as IJavaScriptExecutor;

            CookieJar cookieJar = new CookieJar();
            long      lsSize    = 0;

            lsSize = (long)js.ExecuteScript("return window.localStorage.length;");

            // Loop through all localStorage data
            for (long j = 0; j < lsSize; j++)
            {
                LocalStorageCookie lsData = new LocalStorageCookie();
                lsData.Name = (String)js.ExecuteScript("return window.localStorage.key(" + j + ");");

                // It does not get third party cookies yet, so domain and retrieved from are the same for now
                //lsData.Domain = (new Uri(url).Host).Trim();
                lsData.Type        = "localStorage";
                lsData.DateCreated = DateTime.Now.Ticks;
                lsData.Content     = ((String)js.ExecuteScript("return window.localStorage.getItem('" + lsData.Name + "');"));
                cookieJar.Add(lsData);
            }
            return(cookieJar);
        }
        CookieJar ICookieRetriever.GetCookies(string url)
        {
            CookieJar cookieJar = new CookieJar();

            var cookies = driver.Manage().Cookies.AllCookies;

            // loop to convert all selenium cookies into our HttpCookie object
            foreach (OpenQA.Selenium.Cookie c in cookies)
            {
                HttpCookie theCookie = HttpCookie.ToHttpCookie(c, url);
                cookieJar.Add(theCookie);
            }

            return(cookieJar);
        }
        CookieJar ICookieRetriever.GetCookies(string url)
        {
            if (!Directory.Exists(flashDirectory))
            {
                return(new CookieJar());
            }
            var pathList = Directory.EnumerateFiles(flashDirectory, "*", SearchOption.AllDirectories)
                           .Where(f => f.EndsWith(".sol"));

            CookieJar jar = new CookieJar();

            foreach (String p in pathList)
            {
                System.Diagnostics.Debug.WriteLine(FlashCookie.FromPath(p, url).ToCSVRow());
                jar.Add(FlashCookie.FromPath(p, url));
            }

            return(jar);
        }
        CookieJar ICookieRetriever.GetCookies(string url)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            CookieJar cookieJar = new CookieJar();
            string    domain    = new Uri(url).Host.Trim().Replace("www.", "").Trim();

            var dbPath = ConfigurationManager.AppSettings["HttpCookieDirectory"];

            if (!System.IO.File.Exists(dbPath))
            {
                return(new CookieJar());
            }

            var              connectionString = "Data Source=" + dbPath + ";";
            string           commandText      = "SELECT name,encrypted_value, host_key, expires_utc, path, secure, httponly FROM cookies WHERE host_key LIKE %@domain";
            SQLiteConnection conn             = new System.Data.SQLite.SQLiteConnection(connectionString);
            SQLiteCommand    cmd = new SQLiteCommand(commandText, conn);

            cmd.Parameters.AddWithValue("@domain", domain);
            SQLiteDataReader reader = null;

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var        encryptedData = (byte[])reader[1];
                    var        decodedData   = System.Security.Cryptography.ProtectedData.Unprotect(encryptedData, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);
                    var        plainText     = Encoding.ASCII.GetString(decodedData);
                    HttpCookie c             = new HttpCookie();
                    c.Name        = reader["name"].ToString();
                    c.Domain      = reader["host_key"].ToString();
                    c.Expiry      = new DateTime((long)reader["expires_utc"]).ToString();
                    c.Path        = reader["path"].ToString();
                    c.Type        = "http";
                    c.IsSecure    = (reader["secure"].ToString() == "1");
                    c.IsHttpOnly  = (reader["httponly"].ToString() == "1");
                    c.DateCreated = DateTime.Now.Ticks;
                    c.Content     = plainText;

                    cookieJar.Add(c);
                }
            }
            catch (Exception err)
            {
                Debug.WriteLine(err.ToString());
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conn.Close();
            }
            return(cookieJar);
        }