How to make Gecko use seperate CookieContainer per instance?

≡放荡痞女 提交于 2019-11-28 05:29:55

问题


Since GeckoWebBrowser in .Net shares cookies with all other instances of GeckoWebBrowsers I would like for a GeckoWebBrowser to have it's own cookie container which doesn't share any cookies that was created previously in other GeckoWebBrowsers or other instances.

So for example when I create a GeckoWebBrowser it shouldn't have any cookies. And when I run 2 instances of GeckoWebBrowser they have their own cookie container and don't share or conflict cookies with each other.

How is that possible?


回答1:


You can change the ProfileDirectory which will keep unique copies of cookies (and all other user settings):

string profileDir = "UniqueIdentifier";
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Path.Combine("Geckofx", profileDir));
if (!Directory.Exists(directory))
    Directory.CreateDirectory(directory);
Gecko.Xpcom.ProfileDirectory = directory;


来源:https://stackoverflow.com/questions/18212262/how-to-make-gecko-use-seperate-cookiecontainer-per-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!