DMC*_*MCS 7 javascript cookies http tracking-pixel
我需要能够确定并识别cookie的来源.虽然许多cookie将在原始页面的HTTP响应中进入浏览器,但其他cookie将通过javascript或通过使用http加载到页面上的资产(例如跟踪像素或AJAX调用)添加到浏览器中.
确定/识别每个cookie的来源的好方法是什么?
小智 4
发布此文章是因为我也在为这个问题苦苦挣扎,终于找到了解决方案。
据我所知,这仅在 Firefox 控制台中有效......
您应该在控制台中看到正在创建的每个 cookie 的堆栈跟踪!
origDescriptor = Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie'); // add cookie property to HTMLDocument constructor
Object.defineProperty(document, 'cookie', {
get() {
return origDescriptor.get.call(this);
},
set(value) {
console.log("%c Cookie is :" + value, "background: #ffffff; color: #000000");
console.trace();
// debugger;
return origDescriptor.set.call(this, value);
},
enumerable: true,
configurable: true
});
Run Code Online (Sandbox Code Playgroud)
我必须感谢fflorent在另一个主题中发布的这段代码 - 谢谢!
| 归档时间: |
|
| 查看次数: |
1785 次 |
| 最近记录: |