Reputation: 11740
I am creating cookies using the code given below:
///Cookie
let cookie = {
url: 'http://www.example.com',
name: 'oauthDetailsGoogle',
value: JSON.stringify(oauthDetailsGoogle),
expirationDate: oauthDetailsGoogle.accessTokenExpireDateTime
};
///save cookie
electronConstants().mySession.cookies.set(cookie, (error) => {
///if error then return error
if (error) {
defer.reject(error);
}
///return null if no error
else {
defer.resolve(true);
}
});
In order to delete cookies I am using the following code:
electronConstants().mySession.cookies.remove('http://www.example.com', 'oauthDetailsGoogle', function (data) {
console.log(data);
});
Suppose I have created 10 cookes so in order to delete 10 cookes I will have to call the remove function 10 time with the specific details?
Please guide.. Many thanks
Upvotes: 13
Views: 16895
Reputation: 11740
Finally, I found a solution in Electron Documentation: clearStorageData()
Here is the function that clears everything in one go:
electronConstants().mySession.clearStorageData([], function (data) {
console.log(data);
})
The first parameter takes options
so you can customize what you want to clear. Refer the documentation link that I provided above.
Upvotes: 22