asp.net.ph

HttpCookieCollection.Add Method

System.Web Namespace   HttpCookieCollection Class


Adds the specified cookie to the cookie collection.

[ VB ]
Public Sub Add ( _
   ByVal cookie As HttpCookie _
)

[ C# ]
public void Add (
   HttpCookie cookie
);

[ C++ ]
public: void Add (
   HttpCookie* cookie
);

[ JScript ]
public function Add (
   cookie : HttpCookie
);

Parameters

cookie
The HttpCookie to add to the collection.

Remarks

Any number of cookie collections can exist within an application, but only the collection referenced by the intrinsic Cookies object is sent to the client.

Example

The following example creates a new cookie collection and a new cookie named "LastVisit", sets the value of the cookie to the current date and time, and adds the cookie to the new collection.

[ VB ]
Dim myCookieCollection as New HttpCookieCollection ( ) 
Dim myCookie As New HttpCookie ( "LastVisit" ) 
 myCookie.Value = DateTime.Now ( ).ToString ( ) 
 myCookieCollection.Add ( myCookie )

[ C# ]
HttpCookieCollection myCookieCollection = new HttpCookieCollection ( );
HttpCookie myCookie = new HttpCookie ( "LastVisit" );
myCookie.Value = DateTime.Now.ToString ( );
myCookieCollection.Add ( myCookie );
See Also

HttpCookieCollection Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph