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.Cookie(String, String, String, String) Constructor

Initializes a new instance of the Cookie class with a specified Name, Value, Path, and Domain.

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

Public Sub New ( _
	name As String, _
	value As String, _
	path As String, _
	domain As String _
Dim name As String
Dim value As String
Dim path As String
Dim domain As String

Dim instance As New Cookie(name, value, path, domain)
public Cookie (
	String name, 
	String value, 
	String path, 
	String domain
public function Cookie (
	name : String, 
	value : String, 
	path : String, 
	domain : String
Not applicable.



The name of a Cookie. The following characters must not be used inside name: equal sign, semicolon, comma, newline (\n), return (\r), tab (\t). The dollar sign character ("$") cannot be the first character.


The value of a Cookie object. The following characters must not be used inside value: semicolon, comma.


The subset of URIs on the origin server to which this Cookie applies. The default value is "/".


The optional internet domain for which this Cookie is valid. The default value is the host this Cookie has been received from.

Exception typeCondition


The name parameter is a null reference (Nothing in Visual Basic).


The name parameter is of zero length.


The name parameter contains an invalid character.

The default for the domain and path parameters uses the empty string ("").

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft