'Breaking JavaScript execution when cookie is set
Is it possible to break javascript execution in a browser developer tools always when cookie is set (without setting JS breakpoints explicitly)?
document.cookie = '...';
Solution 1:[1]
This should work (run it in a console):
origDescriptor = Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie');
Object.defineProperty(document, 'cookie', {
get() {
return origDescriptor.get.call(this);
},
set(value) {
debugger;
return origDescriptor.set.call(this, value);
},
enumerable: true,
configurable: true
});
Solution 2:[2]
In Chrome dev-tools, you can right click on a cookie in the application cookies and select 'show request with this cookie'
so it's not an interception, but if your goal is to identify where a cookie comes from then it's a good way.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fflorent |
| Solution 2 | dancl |
