Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gecko clear cache history & cookies

Tags:

c#

cookies

gecko

Help! I use GeckoFx-Windows-10.0-0.6 for browser and xulrunner-10.0.en-US.win32. ( Visual Studio 2010 c# ) everything works well. But i need to clear all history as at Firefox : Tools >> Options >> Privacy

I find how clear cookie over Gecko.CookieManager.RemoveAll();

How clear cache , temp files and history ?!

And when i initialize Gecko.Xpcom i can not clean the folder "Gecko.Xpcom.ProfileDirectory" (where cache and cookie) for obvious reasons. Gecko.Xpcom.Shutdown() does not help


I found a way to clean the cookies via javascript :

var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"].getService(Components.interfa‌​ces.nsICookieManager); cookieManager.removeAll();

How right call this JS in C#?

like image 619
John Avatar asked Nov 22 '12 12:11

John


1 Answers

To clear cookies you will need to query interface like this:

    if (MessageBox.Show("Do you want to delete cookies?", "About to delete all cookies", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
    {
        nsICookieManager CookieMan;
        CookieMan = Xpcom.GetService<nsICookieManager>("@mozilla.org/cookiemanager;1");
        CookieMan = Xpcom.QueryInterface<nsICookieManager>(CookieMan);
        CookieMan.RemoveAll();
    }

An access to cache is denied during runtime brobably cause of security or such. Meaning you will need to find a way to delete these folders after you program closes etc. create another app for handling it.

like image 61
SturmCoder Avatar answered Oct 27 '22 06:10

SturmCoder