我使用chrome.cookies.set在 chrome 扩展中创建 cookie 。我去 site.com,我的 cookie 就设置在那里。一切都很好。在 chrome.cookies.get 的帮助下,我看到了我的 cookie,但在chrome.cookies.getAll 的帮助下,我看不到它们。显示 200 个 cookie 而我的不在 site.com
你能告诉我如何让我的 cookie 显示在chrome.cookies.getAll中吗?
chrome.cookies.set({
'url':'https://site.com/',
'name':'test',
'value':'ok',
'expirationDate': parseInt(new Date().getTime()/1000)+60*60*24
});
chrome.cookies.get({'url':'https://site.com/', 'name':'test'})
chrome.cookies.getAll({})
chrome.cookies.getAll({'url':'https://site.com/'})
如果 chrome.cookies.set 适合你,那么它就会被安装
这个选项:
解决了我的问题。
整个问题是我在 manifest 中设置了权限
"host_permissions": ["https://site.com/*"],并且站点在本地服务器上没有证书,所以在http://site.com/上查找了 cookie 。注册
"host_permissions": ["*://site.com/*"]或"host_permissions": ["<all_urls>"]赚取一切。