CHttpClient::GetFirstCookie Method  
 
BOOL GetFirstCookie(
  LPTSTR lpszCookieName,  
  LPINT lpnNameLen,  
  LPTSTR lpszCookieValue,  
  LPINT lpnValueLen  
);
BOOL GetFirstCookie(
  CString& strCookieName,  
  CString& lpszCookieValue  
);

The GetFirstCookie method returns the first cookie set by the server.

Parameters

lpszCookieName
A pointer to a string buffer which will contain the name of the first cookie set by the server.
lpnNameLen
A pointer to an integer which specifies the maximum number of characters which may be copied into the buffer, including the terminating null character. When the method returns, this value is updated to specify the actual length of the cookie name string.
lpszCookieValue
A pointer to a string buffer which will contain the name of the first cookie value set by the server. If the cookie value is not required, this parameter may be NULL.
lpnValueLen
A pointer to an integer which specifies the maximum number of characters which may be copied into the buffer, including the terminating null character. When the method returns, this value is updated to specify the actual length of the cookie value string. If the lpszCookieValue parameter is NULL, this parameter should also be NULL.

Return Value

If the method succeeds, the return value is non-zero. If there are no cookies or the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The GetFirstCookie method is used to enumerate the cookies set by the server after a resource has been requested. To get information about a specific cookie, use the GetCookie method.

Example

CString strCookieName;
CString strCookieValue;
BOOL bResult;

// Get the first cookie set by the server
bResult = pClient->GetFirstCookie(strCookieName, strCookieValue);

while (bResult)
{
    // The strCookieName and strCookieValue strings contain the
    // the name and value for a cookie set by the server

    // Get the next cookie set by the server
    bResult = pClient->GetNextCookie(strCookieName, strCookieValue);
};

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: cshtpv10.lib

See Also

GetCookie, GetNextCookie, GetHeader, SetCookie, SetHeader