Chrome扩展:在Chrome扩展中设置永久cookie? [英] chrome Extension : Set persistent cookie in chrome extension?
问题描述
我已经通过以下方式设置了Cookie:
chrome.cookies.set({url:http://example.com/,名称:CookieVar,值:123}) ;
但是,当我关闭浏览器数据时,它在当前浏览器中丢失了,所以我将
chrome.cookies.set({url:http://example.com/,名称:CookieVar,值: 123,expirationDate:3600});
但是从这里我无法看到cookie信息是我在这里错过的任何东西。 / p>
预先感谢
看起来您的到期日期是 1970年1月1日00:01
(1表示UNIX纪元后1秒)。所以当然你的cookie将被删除。
你需要为你的cookie提供适当的expirationDate。在文档中, expirationDate
定义为:
cookie的截止日期为自
UNIX纪元以来的秒数
Here I am working with chrome extension development here I need to set cookie value by my extension.
I have set cookies by:
chrome.cookies.set({ url: "http://example.com/", name: "CookieVar", value: "123" });
But it available in current browser when I close browser data was lost so that I going with
chrome.cookies.set({ url: "http://example.com/", name: "CookieVar", value: "123", expirationDate: 3600 });
But from this I am not able to see cookie information is any thing I have missed here..
Advance thanks
It seems that your expiration date is 1 Jan 1970 00:01
(1 means 1 second after UNIX epoch). So of course your cookie will be deleted.
You need to provide appropriate expirationDate for your cookie. In documentation, expirationDate
defined as:
The expiration date of the cookie as the number of seconds since the UNIX epoch
这篇关于Chrome扩展:在Chrome扩展中设置永久cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!