Edit

Share via


Roles.CookieSlidingExpiration Property

Definition

Indicates whether the role names cookie expiration date and time will be reset periodically.

public:
 static property bool CookieSlidingExpiration { bool get(); };
public static bool CookieSlidingExpiration { get; }
static member CookieSlidingExpiration : bool
Public Shared ReadOnly Property CookieSlidingExpiration As Boolean

Property Value

true if the role names cookie expiration date and time will be reset periodically; otherwise, false. The default is true.

Examples

The following example shows the roleManager element in the system.web section of the Web.config file for an ASP.NET application. It specifies that the application uses a SqlRoleProvider instance and sets the CookieSlidingExpiration property to false.

<roleManager defaultProvider="SqlProvider"
  enabled="true"
  cacheRolesInCookie="true"
  cookieName=".ASPROLES"
  cookieTimeout="30"
  cookiePath="/MyApplication"
  cookieRequireSSL="true"
  cookieSlidingExpiration="false"
  cookieProtection="Encrypted" >
  <providers>
    <add
      name="SqlProvider"
      type="System.Web.Security.SqlRoleProvider"
      connectionStringName="SqlServices"
      applicationName="MyApplication" />
  </providers>
</roleManager>

Remarks

You can specify whether role names cookie expiration date and time will be reset with each response by using the cookieSlidingExpiration attribute in the Web.config file for your ASP.NET application. If true, the cookie expiration will initially be set to the current date and time plus the CookieTimeout in minutes. While the user continues to actively use the ASP.NET application, the expiration date and time of the cookie will be automatically refreshed if there is less than half of the CookieTimeout remaining. For more information, see the Expires property.

Applies to

See also