asp.net.ph

Response.Cookies Property

System.Web Namespace   HttpResponse Class


Gets the response cookie collection.

[ VB ]
Public ReadOnly Property Cookies As HttpCookieCollection

[ C# ]
public HttpCookieCollection Cookies {get;}

[ C++ ]
public: __property HttpCookieCollection* get_Cookies ( );

[ JScript ]
public function get Cookies ( ) : HttpCookieCollection;

Property Value

The response cookie collection.

Remarks

The cookie collection accessed through Response.Cookies contains cookies generated on the server and transmitted to the client in the Set-Cookie header.

Response.Cookies is also the syntax used to set the value of a cookie. If the specified cookie does not exist, it is created. If the cookie exists, it takes the new value and the old value is discarded.

Example

The following example creates a new cookie named LastVisit, sets the value of the cookie to the current date and time, and adds the cookie to the current cookie collection. All cookies in the cookie collection are sent to the client in the Set-Cookie header with the HTTP output stream.

HttpCookie myCookie = new HttpCookie ( "LastVisit" );
DateTime now = DateTime.Now;

myCookie.Value = now.ToString ( );
myCookie.Expires = now.AddHours ( 1 );

Response.Cookies.Add ( myCookie );
  C# VB

See Also

HttpResponse 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