Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Cookie Constructor (String, String)

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

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

'Declaration
Public Sub New ( _
	name As String, _
	value As String _
)

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.

ExceptionCondition
CookieException

name is Nothing 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 Nothing 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\"");

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft