我试着用-
let session=require('electron');
session.clearCache(function () {
// console.log("cache clear");
});
session.clearStorageData();
session.defaultSession.cookies.get({}, (error, 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);
});
});
});
getWebContents()
但当我尝试时,“getWebContents()”在控制台上不可用。如何访问webview,然后清除会话,以便下一个用户无法使用上一个用户的凭据登录?