我正在使用nsICookie2来获取firefox for android扩展的现有cookie。当我显示cookie列表及其属性时,我注意到一些非常奇怪的事情,到期时间总是低于创建时间和上次访问时间,exp:
host.bluekai.com expires on 1393031459 time now 1377624200429 cookie creation time 1377479134953422 cookie lasAccessed 1377481998001732
在我的代码中我写了这个:
" host"+coo.host+" expires on "+coo.expiry+" time now "+dd.getTime()+" cookie creationTime "+coo.creationTime+" cookie lastAccessed "+coo.lastAccessed+" \n";
有人可以给我一个合乎逻辑的解释吗?
答案 0 :(得分:0)
不是。一个是秒,其他的是几微秒,你需要缩放:
1393031459 > (1377624200429 / 1000)
nsICookie2:
/**
* the actual expiry time of the cookie, in seconds
* since midnight (00:00:00), January 1, 1970 UTC.
*
* this is distinct from nsICookie::expires, which
* has different and obsolete semantics.
*/
readonly attribute int64_t expiry;
/**
* the creation time of the cookie, in microseconds
* since midnight (00:00:00), January 1, 1970 UTC.
*/
readonly attribute int64_t creationTime;
/**
* the last time the cookie was accessed (i.e. created,
* modified, or read by the server), in microseconds
* since midnight (00:00:00), January 1, 1970 UTC.
*
* note that this time may be approximate.
*/
readonly attribute int64_t lastAccessed;
不可否认,使用不同的时间单位非常困惑。 :P