CookieCount Property  

Return the number of cookies set by the server in response to a request for a resource.




The CookieCount property returns the number of cookies that were set by the server. This value can be used in conjunction with the CookieName and CookieValue properties to enumerate all of the available cookies and their values.

Data Type



' Save the cookies set by a previous request to this server for
' a resource so that they can be sent back with the next request
nCookies = HttpClient1.CookieCount
ReDim strCookieName(nCookies)
ReDim strCookieValue(nCookies)

' Enumerate the available cookies and store them in the array;
' a more complex implementation could use the GetCookie method
' to check for additional information about the cookie, such
' as whether the cookie should be stored locally on the system
For nIndex = 0 To nCookies - 1
  strCookieName(nIndex) = HttpClient1.CookieName(nIndex)
  strCookieValue(nIndex) = HttpClient1.CookieValue(nIndex)

' Clear any previously set headers

' Set each of the cookies that were stored in the array
For nIndex = 0 To nCookies - 1
  HttpClient1.SetCookie strCookieName(nIndex), strCookieValue(nIndex)

' Request the next resource from the server and store
' the data in the strResult string buffer
nError = HttpClient1.GetData(strResource, strResult)

See Also

CookieName Property, CookieValue Property, GetCookie Method, SetCookie Method