我找到了chrome cookie文件的位置,我使用sqliteBrowser打开它并找到cookie表的结构.
我也成功读取了这个文件中的cookie,虽然cookie的值是加密的,但我仍然找到一些方法来解密它.
我还注意到,cookie表的creation_utc字段使用自1601.01.01以来的时间计数.
我想说的是我已经完成了一些工作,并且已经知道了chrome cookies文件的结构.
但问题是,当我要插入一个新的记录,使用C#的System.data.sqlite这个文件,我的计划就是无法插入此记录,并去像锁死一些状态,我注意到,这种情况是由executeNoQuery造成方法不退换!!!
相同的sql语法在我的测试sqlite文件中工作正常,所以我猜这个问题是由chrome cookies文件本身引起的.
谁能帮我?谢谢!
以下是我的代码试图设置cookie:
private static bool SetCookie_Chrome(string strHost, string strField, string value,DateTime expiresDate)
{
bool fRtn = false;
string strPath, strDb;
strPath = GetChromeCookiePath();
//strPath= GetTestCookiePath();
if (string.Empty == strPath) // Nope, perhaps another browser
return false;
try
{
strDb = "Data Source=" + strPath + ";pooling=false";
SQLiteConnection conn = new SQLiteConnection(strDb);
SQLiteCommand cmd = conn.CreateCommand();
Byte[] encryptedValue=getEncryptedValue(value);
cmd.CommandText = "INSERT INTO `cookies`(`creation_utc`,`host_key`,`name`,`value`,`path`,`expires_utc`,`secure`,`httponly`,`last_access_utc`,`has_expires`,`persistent`,`priority`,`encrypted_value`) "+
"VALUES ("+TimeUtil.get_creation_utc()+",'"+strHost+"','"+strField+"','','/',"+
TimeUtil.get_specific_utc(expiresDate.Year,expiresDate.Month,expiresDate.Day,expiresDate.Hour,expiresDate.Minute,expiresDate.Second)+
",0,0," + TimeUtil.get_creation_utc() + ",1,1,1,@evalue);"; …Run Code Online (Sandbox Code Playgroud)