3

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?

EBAG
  • 21,625
  • 14
  • 59
  • 93

1 Answers1

4

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;
Sire
  • 4,086
  • 4
  • 39
  • 74
  • i have tried this but its not working , browser sharing the cookies with each other – yasmuru Dec 26 '13 at 05:14
  • It works fine for me. You understood that you need to change the string "UniqueIdentifier" for each instance? So it needs to be "UniqueIdentifier1", "UniqueIdentifier2" etc. – Sire Jan 03 '14 at 11:47
  • I have changed the name and its creating the folder too but the starting folder only accessed by other instances. – yasmuru Jan 07 '14 at 05:51
  • 1
    You need to set the ProfileDirectory before you start any instance of the web browser. And it might not be possible to change while the application is running. – Sire Jan 08 '14 at 09:23
  • If we cant change "ProfileDirectory" at run time then there is no use in multithreading option – yasmuru Jan 08 '14 at 12:55