Export (0) Print
Expand All

HttpCookie.Expires Property

Gets or sets the expiration date and time for the cookie.

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

public DateTime Expires { get; set; }
/** @property */
public DateTime get_Expires ()

/** @property */
public void set_Expires (DateTime value)

public function get Expires () : DateTime

public function set Expires (value : DateTime)

Property Value

The time of day (on the client) at which the cookie expires.

The following code example sets the expiration time of the cookie to 10 minutes from the current time.

DateTime dt = DateTime.Now;
 TimeSpan ts = new TimeSpan(0,0,10,0);
 MyCookie.Expires = dt.Add(ts);

DateTime dt = DateTime.get_Now();
TimeSpan ts = new TimeSpan(0, 0, 10, 0);

var dt : DateTime = DateTime.Now
var ts : TimeSpan = new TimeSpan(0,0,10,0)

myCookie.Expires = dt.Add(ts)

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.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2014 Microsoft