Reputation: 5412
I am only able to grab cookies with the same domain, but when you view the cookies in the chrome dev tool, you can see a bunch of cookies with different domain values under the same url tree tab on the right like below. The circled cookie is from a different domain for example but show up under developer.chrome.com.
My question is how do you pull all the cookies from that domain tab with different domain values?
chrome.cookies.getAll({'url': "http://developer.chrome.com"}, function (cookies) {
if (cookies) {
console.log(cookies); //will only pull cookies with domain value developer.chrome.com
}
});
Upvotes: 3
Views: 5657
Reputation: 1
document.cookie
won't give you access to the cookie from a script unless the HttpOnly
flag has not been set by the web application whose cookies you're trying to access.
Also, you can't make cross-domain
cookie requests unless there's an XSS or similar vulnerability.
The Chrome extension mentioned above seems able to inspect all browser traffic (cross domain) and pull the cookies from that traffic, although I haven't tried it myself so could be wrong on that point.
Upvotes: 0
Reputation: 3459
You need to inspect the requests being made on a tab to see which are making requests for cross-domain cookies.
In order to access the network api, you need to make a DevTools extension [info].
From there you need to make the following request:
chrome.devtools.network.getHAR()
This will log json regarding the network requests being made. In that json, you can access a cookie object. The json is based on the HAR spec. [info]
Upvotes: 2
Reputation: 1315
You can read all your cookies by accessing document.cookie
and parse accordingly.
See an example here
Upvotes: 2