protected async Task SetCookieAsync( Controls.WinForms.WebView webView, string cookieName, string cookieValue, DateTime?expiry = null) { string formatExpiry(DateTime?e) => e != null ? $"; expires={e.Value.ToUniversalTime():R}" : string.Empty; var cookie = $"{cookieName}={cookieValue}{formatExpiry(expiry)}"; if (webView != null) { await webView.InvokeScriptAsync("eval", $"document.cookie = \"{cookie}\"").ConfigureAwait(false); } }
protected Task <string> GetCookiesAsync(Controls.WinForms.WebView webView) { return(webView.InvokeScriptAsync("eval", "document.cookie")); }