【发布时间】:2014-07-25 16:29:30
【问题描述】:
C# Chrome SQLite 值未读取? Mozilla cookie 值已读取,但 chrome cookie 值 null。读取此 cookie 值的正确方法是什么?
//String connString = "Data Source=C:\\Users\\XXXX\\AppData\\Roaming\\Opera Software\\Opera Stable\\Cookies;Version=3;New=False;Compress=True;";
String connString = "Data Source=C:\\Users\\XXXX\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cookies;Version=3;New=False;Compress=True;";
//String connString = "Data Source=C:\\Users\\XXXX\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\eac8q0hd.default\\cookies.sqlite";
using (SQLiteConnection conn = new SQLiteConnection(connString))
{
StringBuilder query = new StringBuilder();
//chrome
query.Append("SELECT value FROM cookies WHERE host_key LIKE '%.search.cpan.org%' AND name LIKE '%__utmc%';");
//mozilla
//query.Append("SELECT value FROM moz_cookies WHERE host LIKE '%.oasgames.com%' AND name LIKE '%__utmz%';");
//query.Append("ORDER BY name");
using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), conn))
{
conn.Open();
using (SQLiteDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
textBox1.Text = dr.GetValue(0).ToString();
// textBox1.Text = dr.GetValue(0) + " " + dr.GetValue(1) + " " + dr.GetValue(2) + " " + dr.GetValue(3) + " " + dr.GetValue(4) + " " + dr.GetValue(5);
}
}
}
}
【问题讨论】:
-
使用 sqlite3.exe 直接浏览 sqlite 文件 - 那里的值可以访问/列出吗?
-
不,这不起作用。值为空
-
我遇到了和你一样的问题。你解决了吗?
标签: c# google-chrome cookies