如果你想要获取当前网页真的所有cookie的话,下面的代码没啥用.因为我发现有些cookie取不出来.只能手动.
var arr=[];
var cookies=document.cookie;
// console.log("未截取时"+cookies);
while(cookies.indexOf(';') != -1){
var a = cookies.slice(0,cookies.indexOf(';'));
arr.push('document.cookie="'+a+'"');
cookies=cookies.slice(cookies.indexOf(';')+1);
console.log(arr);
// console.log("剩余的"+cookies);
}
arr.push('document.cookie="'+cookies+'"');
var str=arr.join(';').replaceAll('" ','"');
console.log(str);
console.log(str.length);
–
var arr=[];
var cookies=document.cookie;
console.log("未截取时"+cookies);
while(cookies.indexOf(';') != -1){
var a = cookies.slice(0,cookies.indexOf(';'));
arr.push(a);
cookies=cookies.slice(cookies.indexOf(';')+1);
console.log(arr);
console.log("剩余的"+cookies);
}
arr.push(cookies);
–
发表回复