HttpResponse.Cookies Property
.NET Framework 3.0
Gets the response cookie collection.
Namespace: System.Web
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public ReadOnly Property Cookies As HttpCookieCollection 'Usage Dim instance As HttpResponse Dim value As HttpCookieCollection value = instance.Cookies
/** @property */ public HttpCookieCollection get_Cookies ()
public function get Cookies () : HttpCookieCollection
Not applicable.
Property Value
The response cookie collection.ASP.NET includes two intrinsic cookie collections. The collection accessed through the Cookies collection of HttpRequest contains cookies transmitted by the client to the server in the Cookie header. The collection accessed through the Cookies collection of HttpResponse contains new cookies created on the server and transmitted to the client in the Set-Cookie header.
| Topic | Location |
|---|---|
| How to: Write a Cookie | Building ASP .NET Web Applications |
| How to: Delete a Cookie | Building ASP .NET Web Applications |
| How to: Write a Cookie | Building ASP .NET Web Applications |
| How to: Delete a Cookie | Building ASP .NET Web Applications |
The following code 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.
Dim MyCookie As New HttpCookie("LastVisit") Dim now As DateTime = DateTime.Now MyCookie.Value = now.ToString() MyCookie.Expires = now.AddHours(1) Response.Cookies.Add(MyCookie)
HttpCookie myCookie = new HttpCookie("LastVisit");
DateTime now = DateTime.get_Now();
myCookie.set_Value(now.ToString());
myCookie.set_Expires(now.AddHours(1));
get_Response().get_Cookies().Add(myCookie);
var myCookie : HttpCookie = new HttpCookie("LastVisit") var now : DateTime = DateTime.Now myCookie.Value = now.ToString() myCookie.Expires = now.AddHours(1) Response.Cookies.Add(myCookie)
Community Additions
ADD
Show: