0 out of 1 rated this helpful - Rate this topic

HttpCookie.Secure Property

Gets or sets a value indicating whether to transmit the cookie using Secure Sockets Layer (SSL)--that is, over HTTPS only.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)
public bool Secure { get; set; }

Property Value

Type: System.Boolean
true to transmit the cookie over an SSL connection (HTTPS); otherwise, false. The default value is false.

To set the transmission of cookies using SSL for an entire application, enable it in the application's configuration file, Web.config, which resides in the root directory of the application. For more information, see httpCookies Element (ASP.NET Settings Schema). Values set programmatically using the Secure property override values set in the Web.config file.

When dealing with sensitive information, it is strongly recommended that you use HTTPS protocol with SSL encryption. SSL protects against data being altered (data integrity), protects a user's identity (confidentiality), and assures that data originates from the expected client (authentication). For more information on the benefits of encryption, see Cryptographic Services. For more information about configuring SSL on an Internet Information Services (IIS) Web server, see Configuring SSL on a Web Server or a Web Site.

The following code example takes action if the cookie is set to transmit using SSL.


if (MyCookie.Secure)
 {
   //...
 }
    


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.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.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Oddly it is only applicable to the client side send.
If you are trying to ensure you do not "send" sensitive data in the raw you'll need to code around this before calling it.  It's up to you on the server side it appears to ensure its safe to transmit. The browser takes care from the client side not to resend it to you unless it is secure - but by then it could be too late. Date received thanks - switch to https and away we go.