This documentation is archived and is not being maintained.
HttpCookie.Expires Property
.NET Framework 1.1
Gets or sets the expiration date and time for the cookie.
[Visual Basic] Public Property Expires As DateTime [C#] public DateTime Expires {get; set;} [C++] public: __property DateTime get_Expires(); public: __property void set_Expires(DateTime); [JScript] public function get Expires() : DateTime; public function set Expires(DateTime);
Property Value
The time of day (on the client) at which the cookie expires.
Example
The following example sets the expiration time of the cookie to 10 minutes from the current time.
[Visual Basic] Dim dt As DateTime = DateTime.Now() Dim ts As New TimeSpan(0,0,10,0) MyCookie.Expires = dt.Add(ts) [C#] DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(0,0,10,0); MyCookie.Expires = dt.Add(ts); [C++] DateTime dt = DateTime::Now; TimeSpan ts = TimeSpan(0,0,10,0); MyCookie->Expires = dt.Add(ts); [JScript] var dt : DateTime = DateTime.Now var ts : TimeSpan = new TimeSpan(0,0,10,0) myCookie.Expires = dt.Add(ts)
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
HttpCookie Class | HttpCookie Members | System.Web Namespace
Show: