Redigera

Dela via


HttpCookie.Secure Property

Definition

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

public:
 property bool Secure { bool get(); void set(bool value); };
public bool Secure { get; set; }
member this.Secure : bool with get, set
Public Property Secure As Boolean

Property Value

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

Examples

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

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

If MyCookie.Secure Then
    '...
 End If
    

Remarks

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.

Applies to

See also