This documentation is archived and is not being maintained.

HttpCookie Constructor

.NET Framework 1.1

Initializes a new instance of the HttpCookie class.

Overload List

Creates and names a new cookie.

[Visual Basic] Public Sub New(String)
[C#] public HttpCookie(string);
[C++] public: HttpCookie(String*);
[JScript] public function HttpCookie(String);

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

[Visual Basic] Public Sub New(String, String)
[C#] public HttpCookie(string, string);
[C++] public: HttpCookie(String*, String*);
[JScript] public function HttpCookie(String, String);

Example

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

[Visual Basic] 
Dim MyCookie As New HttpCookie("LastVisit", CStr(DateTime.Now()))
    

[C#] 
HttpCookie MyCookie = new HttpCookie("LastVisit", 
    DateTime.Now.ToString());
    

[C++] 
HttpCookie* MyCookie = new HttpCookie(S"LastVisit", 
    DateTime::Now.ToString());
    

[JScript] 
var myCookie : HttpCookie = new HttpCookie("LastVisit", String(DateTime.Now))
    

See Also

HttpCookie Class | HttpCookie Members | System.Web Namespace

Show: