Assembly: System.Web (in system.web.dll)
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.
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.
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);
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.