Dela via


HttpCookie(String, String, String) Constructor

Definition

Initializes a new instance of the HttpCookie class with a specified name, domain, and path.

public:
 HttpCookie(Platform::String ^ name, Platform::String ^ domain, Platform::String ^ path);
 HttpCookie(winrt::hstring const& name, winrt::hstring const& domain, winrt::hstring const& path);
public HttpCookie(string name, string domain, string path);
function HttpCookie(name, domain, path)
Public Sub New (name As String, domain As String, path As String)

Parameters

name
String

Platform::String

winrt::hstring

The name for the HttpCookie

domain
String

Platform::String

winrt::hstring

The domain for which the HttpCookie is valid.

path
String

Platform::String

winrt::hstring

The URIs to which the HttpCookie applies.

Remarks

The name parameter of the HttpCookie can't be set to null (Nothing in Visual Basic).

The property should be a token as defined in RFC 2616 and RFC 6265.

The following characters are used as separators and can't be used in the name parameter:

  • left paren ('(')
  • right paren (')')
  • greater than ('>')
  • less than ('<')
  • at sign ('@')
  • comma (',')
  • semicolon (';')
  • colon (':')
  • backslash ('\')
  • double quote ('"')
  • forward slash ('/')
  • left square bracket ('[')
  • right square bracket (']')
  • question mark ('?')
  • equal sign ('=')
  • left squiggly bracket ('{')
  • right squiggly bracket ('}')
  • new line ('\n')
  • return ('\r")
  • space (' ')
  • tab ('\t")

The *domain * parameter specifies those hosts to which the HttpCookie will be sent. A cookie with a *domain * parameter of .contoso.com will be sent to the contoso.com domain and all subdomains (www.contoso.com and info.contoso.com, for example).

A cookie with a *domain * parameter of info.contoso.com will not be sent to contoso.com or www.contoso.com, but will be sent to info.contoso.com and all subdomains (uk.info.contoso.com and us.info.contoso.com, for example).

If the domain parameter is not specified, then the HttpCookie will be sent only to the host and subdomains of the host that this cookie was received from.

The path parameter specifies the subset of paths on the origin server to which this HttpCookie applies. If this parameter is not specified, the default path matches any path and the HttpCookie will be sent on all HTTP requests to the *domain * parameter specified and all subdomains.

Applies to