HttpCookiesSection Class

This class supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Configures properties for cookies used by a Web application.

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

public sealed class HttpCookiesSection : ConfigurationSection
public final class HttpCookiesSection extends ConfigurationSection
public final class HttpCookiesSection extends ConfigurationSection
Not applicable.

The HttpCookiesSection class provides a way to programmatically access and modify the httpCookies section of a configuration file.

It defines the settings applied by default to all cookies issued by the application, unless the code issuing the cookie overrides them.

One objective of the httpCookies element is to support the use of HttpOnly cookies. HttpOnly cookies (cookies with the HttpOnly attribute) were introduced in Internet Explorer 6 to help mitigate the risk of cross-site scripting. The HttpOnly attribute prevents cookies from being accessed through client-side script. Any information contained in an HttpOnly cookie is less likely to be disclosed to a hacker or a malicious Web site. For more information, search MSDN ( for "HttpOnly."


The HttpCookiesSection can read and write information from and to the related section of the configuration file according to the section property AllowDefinition whose value is Everywhere.

The following code example shows how to obtain the HttpCookiesSection object from the configuration file of an existing Web application.

// Get the Web application configuration.
System.Configuration.Configuration webConfig =

// Get the section.
string configPath = "system.web/httpCookies";
System.Web.Configuration.HttpCookiesSection httpCookiesSection =

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions