const {session} = require(‘electron‘);
// 查询所有 cookies。删除。
session.defaultSession.cookies.get({})
.then((cookies) => {
cookies.forEach(cookie => {
let url = ‘‘;
// get prefix, like https://www.
url += cookie.secure ? ‘https://‘ : ‘http://‘;
url += cookie.domain.charAt(0) === ‘.‘ ? ‘www‘ : ‘‘;
// append domain and path
url += cookie.domain;
url += cookie.path;
session.defaultSession.cookies.remove(url, cookie.name, (error) => {
if (error) console.log(`error removing cookie ${cookie.name}`, error);
});
})
}).catch((error) => {
console.log(error)
})
原文:https://www.cnblogs.com/sxdjy/p/13065559.html