如何使Gecko每个实例使用单独的CookieContainer
本文关键字:单独 CookieContainer 实例 何使 Gecko | 更新日期: 2023-09-27 18:27:40
由于.Net中的GeckoWebBrowser与GeckoWeb浏览器的所有其他实例共享cookie,我希望Gecko韦伯浏览器拥有自己的cookie容器,该容器不共享以前在其他Geckoweb浏览器或其他实例中创建的任何cookie。
例如,当我创建GeckoWebBrowser时,它不应该有任何cookie。当我运行GeckoWebBrowser的两个实例时,它们有自己的cookie容器,彼此之间不共享或冲突cookie。
这怎么可能?
您可以更改ProfileDirectory,它将保留cookie的唯一副本(以及所有其他用户设置):
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;