Configures properties for cookies used by a Web application.
Assembly: System.Web (in System.Web.dll)
The 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 (msdn.microsoft.com) for "HttpOnly."
The following code example shows how to obtain the object from the configuration file of an existing Web application.
// Get the Web application configuration. System.Configuration.Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("/aspnetTest"); // Get the section. string configPath = "system.web/httpCookies"; System.Web.Configuration.HttpCookiesSection httpCookiesSection = (System.Web.Configuration.HttpCookiesSection)webConfig.GetSection( configPath);
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.