HttpCookieCollection.Set Method (HttpCookie)

 

Updates the value of an existing cookie in a cookie collection.

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

public void Set(
	HttpCookie cookie
)

Parameters

cookie
Type: System.Web.HttpCookie

The HttpCookie object to update.

The Set method first checks to see if a cookie already exists in the collection and if so updates it. The Set method does not allow duplicate cookies in the cookie collection. To add duplicate cookies in the cookie collection, use the Add method.

The following example updates the value of an existing cookie.

MyCookie.Value = DateTime.Now.ToString();
 MyCookieCollection.Set(MyCookie);

.NET Framework
Available since 1.1
Return to top
Show: