2

我正在使用 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";

谁能给我一个合乎逻辑的解释?

4

1 回答 1

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

于 2013-08-27T17:44:55.723 回答