HttpCookie.HasKeys Property

 

Gets a value indicating whether a cookie has subkeys.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

Public ReadOnly Property HasKeys As Boolean

Property Value

Type: System.Boolean

true if the cookie has subkeys, otherwise, false. The default value is false.

The following code example examines each member of a cookie collection for multiple values. If a cookie's HasKeys property is true, indicating that multiple values are present, this example copies the value names into one string array and the corresponding values into another string array. For an example of how to create multiple values for a cookie, see Values.

Dim MyCookieCollection As HttpCookieCollection
Dim MyCookie As HttpCookie
Dim MyKeyNames() As String
Dim MyValues() As String
Dim loop1 As Integer

MyCookieCollection = Request.Cookies
For loop1 = 0 To MyCookieCollection.Count - 1
    MyCookie = MyCookieCollection(loop1)
    If MyCookie.HasKeys Then
        Dim MyCookieValues As NameValueCollection = _
            New NameValueCollection(MyCookie.Values)
        MyKeyNames = MyCookieValues.AllKeys
        For Each KeyName As String In MyKeyNames
            MyValues = MyCookieValues.GetValues(KeyName)
        Next
    End If
Next loop1

.NET Framework
Available since 1.1
Return to top
Show: