Export (0) Print
Expand All

RoleManagerSection.CacheRolesInCookie Property

Gets or sets a value indicating whether the current user's roles are cached in a cookie.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

[ConfigurationPropertyAttribute("cacheRolesInCookie", DefaultValue = false)]
public bool CacheRolesInCookie { get; set; }

Property Value

Type: System.Boolean
true if the current user's roles are cached in a cookie; otherwise, false. The default is false.

The CacheRolesInCookie property returns a Boolean value indicating whether cookie storage for role names is enabled.

When the CacheRolesInCookie property is set to true in the configuration file, role information for each user is stored in a cookie on the client. When role management checks to determine whether a user is in a particular role, the roles cookie is checked before calling the role provider to check the list of roles at the data source. The cookie is dynamically updated on the client to cache the most recently validated role names.

You can improve the reliability of the role names that are cached in a cookie by specifying a CookieProtection property when you configure the roleManager section of the configuration file. The default CookieProtection property is All, which encrypts role names in the cookie and validates that the cookie contents have not been altered.

The following code example demonstrates how to use the CacheRolesInCookie property. This code example is part of a larger example provided for the RoleManagerSection class.

// Display CacheRolesInCookie property.
Console.WriteLine("CacheRolesInCookie: {0}",

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2014 Microsoft