Editar

Partilhar via


HttpCookie Constructors

Definition

Initializes a new instance of the HttpCookie class.

Overloads

HttpCookie(String)

Creates and names a new cookie.

HttpCookie(String, String)

Creates, names, and assigns a value to a new cookie.

HttpCookie(String)

Creates and names a new cookie.

public:
 HttpCookie(System::String ^ name);
public HttpCookie (string name);
new System.Web.HttpCookie : string -> System.Web.HttpCookie
Public Sub New (name As String)

Parameters

name
String

The name of the new cookie.

Examples

The following code example creates and names a new cookie.

HttpCookie MyCookie = new HttpCookie("LastVisit");

Dim MyCookie As New HttpCookie("LastVisit")
    

Applies to

HttpCookie(String, String)

Creates, names, and assigns a value to a new cookie.

public:
 HttpCookie(System::String ^ name, System::String ^ value);
public HttpCookie (string name, string value);
new System.Web.HttpCookie : string * string -> System.Web.HttpCookie
Public Sub New (name As String, value As String)

Parameters

name
String

The name of the new cookie.

value
String

The value of the new cookie.

Examples

The following code example creates, names, and sets the value of a new cookie.

HttpCookie MyCookie = new HttpCookie("LastVisit",
    DateTime.Now.ToString());

Dim MyCookie As New HttpCookie("LastVisit", CStr(DateTime.Now()))
    

Applies to