Cookie Constructor (String, String, String)
Collapse the table of content
Expand the table of content

Cookie Constructor (String, String, String)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Initializes a new instance of the Cookie class with the specified name, value and path.

Namespace:  System.Net
Assembly:  System.Net (in System.Net.dll)

public Cookie(
	string name,
	string value,
	string path
)

Parameters

name
Type: System.String
The name of the Cookie. The name parameter cannot contain the following characters: equal sign (=), semicolon (;), comma (,), newline (\n), return (\r), tab (\t), and space character. The dollar sign character ($) cannot be the first character.
value
Type: System.String
The value for the Cookie. The value parameter cannot contain a semicolon (;) or a comma (,) unless they are contained in escaped double quotes.
path
Type: System.String
The path portion of a URI to which this cookie applies.

ExceptionCondition
CookieException

name is null or an empty string ("").

-or-

name contains an unauthorized character. Using one of the following characters will cause an exception:

  • equal sign (=)

  • semicolon (;)

  • comma (,)

  • newline (\n)

  • return (\r)

  • tab (\t)

  • space character

  • dollar sign ($) as the first character

-or-

value is null or contains a semicolon (;) or a comma (,) that is not contained in escaped double quotes.

The comma character is reserved for use as a delimiter to separate cookies on the same line. The following example shows how to use a comma inside a value parameter:

System.Net.Cookie cookie = new System.Net.Cookie("cookieID", "\"123,456\"");

The following illustration indicates the domain and path portion of a Uniform Resource Identifier (URI).

Domain and path portion of a URI

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft