DMyrzich
DMyrzich

Reputation: 81

set cookie dotnetbrowser. what do I do not so why cookies won't be connected to inquiry?

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/");

Upvotes: 0

Views: 491

Answers (1)

Vladyslav Tsvek
Vladyslav Tsvek

Reputation: 259

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

Upvotes: 0

Related Questions