简体   繁体   English

javascript Chrome扩展程序无法读取httponly Cookie

[英]javascript Chrome Extension Not able to read httponly cookies

I need to delete gmail cookies set in my chrome browser, using chrome extension , but it can delete all cookies other then Gmail cookies, then I noticed that Gmail cookies are httponly, Is there a way to remove them using javascript chrome extension.. 我需要使用Chrome扩展程序删除我的Chrome浏览器中设置的gmail cookie,但它可以删除除Gmail cookie之外的所有cookie,然后我注意到Gmail cookie是httponly,有没有办法使用javascript chrome扩展删除它们..

Thanks :) 谢谢 :)

Chrome extensions can use chrome.cookies API, that has access to all cookies in the cookie store, including httpOnly . Chrome扩展程序可以使用chrome.cookies API,该API可以访问Cookie商店中的所有Cookie,包括httpOnly

The documentation for the API is here . API的文档在这里

Note that this API requires declaring a permission and will not work from content scripts. 请注意,此API需要声明权限,并且无法使用内容脚本。

This one works absolutely fine for deleting every cookie, even if it is httponly 这个对于删除每个cookie都非常好,即使它是httponly

chrome.cookies.getAll({'domain':'accounts.google.com'},function(cookie){ 

    for(i=0;i<cookie.length;i++){

    var prefix = "https://";

    var url =  prefix + cookie[i].domain + cookie[i].path;

    chrome.cookies.remove({'url':url , 'name':cookie[i].name},function(cookie){ });             
    }       
 }); 

The point of HTTPOnly cookies is not let javascript to access them. HTTPOnly cookie的重点是不允许javascript访问它们。 So basically you can not read them. 所以基本上你不能读它们。 If you want to delete them you can do it from the options that offers browser 如果要删除它们,可以从提供浏览器的选项中进行删除

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM