MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / SetCookie

Method SetCookie

cpp/iedriver/CookieManager.cpp:61–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61int CookieManager::SetCookie(const std::string& url,
62 const BrowserCookie& cookie) {
63 std::string full_data = url + "|" + cookie.ToString();
64 WPARAM set_flags = 0;
65 if (cookie.is_httponly()) {
66 set_flags = INTERNET_COOKIE_HTTPONLY;
67 }
68
69 HookSettings hook_settings;
70 hook_settings.hook_procedure_name = "CookieWndProc";
71 hook_settings.hook_procedure_type = WH_CALLWNDPROC;
72 hook_settings.window_handle = this->window_handle_;
73 hook_settings.communication_type = OneWay;
74
75 HookProcessor hook;
76 if (!hook.CanSetWindowsHook(this->window_handle_)) {
77 LOG(WARN) << "Cannot set cookie because driver and browser are not the "
78 << "same bit-ness.";
79 return EUNHANDLEDERROR;
80 }
81 hook.Initialize(hook_settings);
82 hook.PushData(StringUtilities::ToWString(full_data));
83 ::SendMessage(this->window_handle_, WD_SET_COOKIE, set_flags, NULL);
84 int status = HookProcessor::GetDataBufferSize();
85 if (status != 0) {
86 LOG(WARN) << "Setting cookie encountered error " << status;
87 return EINVALIDCOOKIEDOMAIN;
88 }
89 return WD_SUCCESS;
90}
91
92int CookieManager::GetCookies(const std::string& url,
93 std::vector<BrowserCookie>* all_cookies) {

Callers 2

RecurseCookieDomainMethod · 0.95
ExecuteInternalMethod · 0.80

Calls 6

is_httponlyMethod · 0.80
CanSetWindowsHookMethod · 0.80
PushDataMethod · 0.80
LOGClass · 0.50
ToStringMethod · 0.45
InitializeMethod · 0.45

Tested by

no test coverage detected