Class CoreWebView2CookieManager
Creates, adds or updates, gets, or or view the cookies.
public class CoreWebView2CookieManager
  - Inheritance
 - 
      
      CoreWebView2CookieManager
 
- Inherited Members
 
Remarks
The changes would apply to the context of the user profile. That is, other WebViews under the same user profile could be affected.
Methods
AddOrUpdateCookie(CoreWebView2Cookie)
Adds or updates a cookie with the given cookie data; may overwrite cookies with matching name, domain, and path if they exist.
public void AddOrUpdateCookie(CoreWebView2Cookie cookie)
  Parameters
cookieCoreWebView2CookieThe CoreWebView2Cookie to be added or updated.
Examples
Remarks
This method will fail if the domain of the given cookie is not specified.
CopyCookie(CoreWebView2Cookie)
Creates a cookie whose params matches those of the specified cookie.
public CoreWebView2Cookie CopyCookie(CoreWebView2Cookie cookieParam)
  Parameters
cookieParamCoreWebView2Cookie
Returns
CreateCookie(string, string, string, string)
Creates a cookie object with a specified name, value, domain, and path.
public CoreWebView2Cookie CreateCookie(string name, string value, string Domain, string Path)
  Parameters
namestringThe name for the CoreWebView2Cookie to be created. It cannot start with whitespace(s).
valuestringDomainstringPathstring
Returns
Remarks
One can set other optional properties after cookie creation. This only creates a cookie object and it is not added to the cookie manager until you call AddOrUpdateCookie(CoreWebView2Cookie). name that starts with whitespace(s) is not allowed.
CreateCookieWithSystemNetCookie(Cookie)
Creates a CoreWebView2Cookie object whose params matches those of the given System.Net.Cookie.
public CoreWebView2Cookie CreateCookieWithSystemNetCookie(Cookie systemNetCookie)
  Parameters
systemNetCookieCookieA System.Net.Cookie whose params to be used to create a CoreWebView2Cookie.
Returns
- CoreWebView2Cookie
 An object whose Name, Value, Path, Domain, IsHttpOnly, IsSecure, and Expires, matches those Name, Value, Path, Domain, HttpOnly, Secure, and Expires of the given Cookie object.
Remarks
The default value for the SameSite property of the returned CoreWebView2Cookie object is Lax.
- See Also
 
DeleteAllCookies()
Deletes all cookies under the same profile.
public void DeleteAllCookies()
  Remarks
This could affect other WebViews under the same user profile.
DeleteCookie(CoreWebView2Cookie)
Deletes a cookie whose name and domain/path pair match those of the specified cookie.
public void DeleteCookie(CoreWebView2Cookie cookie)
  Parameters
cookieCoreWebView2Cookie
DeleteCookies(string, string)
Deletes cookies with matching name and uri.
public void DeleteCookies(string name, string uri)
  Parameters
namestringThe name for the cookies to be deleted is required.
uristringIf uri is specified, deletes all cookies with the given name where domain and path match provided URI.
DeleteCookiesWithDomainAndPath(string, string, string)
Deletes cookies with matching name and domain/path pair.
public void DeleteCookiesWithDomainAndPath(string name, string Domain, string Path)
  Parameters
namestringThe name for the cookies to be deleted is required.
DomainstringIf domain is specified, deletes only cookies with the exact domain.
PathstringIf path is specified, deletes only cookies with the exact path.
GetCookiesAsync(string)
Gets a list of cookies matching the specific URI.
public Task<List<CoreWebView2Cookie>> GetCookiesAsync(string uri)
  Parameters
uristringIf uri is empty string or null, all cookies under the same profile are returned.
Returns
Examples
Remarks
You can modify the cookie objects by calling AddOrUpdateCookie(CoreWebView2Cookie), and the changes will be applied to the webview.