0

Not Cookies, why aren't established?? what do I do not so why cookies won't be connected to inquiry?

String dataDir = Path.GetFullPath("chromium-data");
BrowserContextParams params1 = new BrowserContextParams(dataDir);
BrowserContext context1 = new BrowserContext(params1);
Browser browser = BrowserFactory.Create(context1);

CookieStorage cookieStorage = browser.CookieStorage;
cookieStorage.SetSessionCookie("https://vk.com/", "ggggggg", "jnjnjnjnjnjnj", "vk.com", dataDir, true, false);
cookieStorage.Save();

browser.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";        

browser.LoadURL("https://vk.com/");
smn.tino
  • 2,272
  • 4
  • 32
  • 41
DMyrzich
  • 81
  • 1
  • 5

1 Answers1

0

You should use another session cookies path because session cookies are stored in application memory. Session cookies will be removed automatically when the corresponding application terminates.

Here is a code snippet which demonstrates how you can set it in your case:

cookieStorage.SetSessionCookie( "https://vk.com/", "ggggggg", "jnjnjnjnjnjnj", "vk.com", "/", true, false);

Also, this method returns the bool value which represents if a session cookie is inserted successfully.

This article contains more information about how to work with CookieStorage: https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110182-working-with-cookiestorage

Vladyslav Tsvek
  • 244
  • 1
  • 10