.NET Framework Class Library
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)
Syntax

Visual Basic (Declaration)
Public Property Secure As Boolean
Visual Basic (Usage)
Dim instance As HttpCookie
Dim value As Boolean

value = instance.Secure

instance.Secure = value
C#
public bool Secure { get; set; }
Visual C++
public:
property bool Secure {
    bool get ();
    void set (bool value);
}
JScript
public function get Secure () : boolean
public function set Secure (value : boolean)

Property Value

Type: System..::.Boolean
true to transmit the cookie over an SSL connection (HTTPS); otherwise, false. The default value is false.
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 Cryptography Overview. 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.

Examples

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

Visual Basic
If MyCookie.Secure Then
    '...
 End If

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

JScript
if(myCookie.Secure){
    //...
 }

Platforms

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also

Reference

Other Resources

Tags :


Page view tracker