InternetGetCookieEx2 function (wininet.h)

Retrieves one or more cookies associated with the specified URL.

Syntax

DWORD InternetGetCookieEx2(
  PCWSTR           pcwszUrl,
  PCWSTR           pcwszCookieName,
  DWORD            dwFlags,
  INTERNET_COOKIE2 **ppCookies,
  PDWORD           pdwCookieCount
);

Parameters

pcwszUrl

The URL for which to retrieve cookies.

pcwszCookieName

The name of the cookie to retrieve. May be NULL.

dwFlags

Flags of the cookie to retrieve. The following flags are available.

Value Meaning
INTERNET_COOKIE_THIRD_PARTY Retrieve cookies as a third party, causing first-party-only cookies to be excluded.
INTERNET_COOKIE_NON_SCRIPT Indicate that this query was not triggered via JavaScript, allowing retrieval of HTTP-only cookies.
INTERNET_COOKIE_SAME_SITE_LEVEL_CROSS_SITE Retrieve cookies as if in a cross site context, excluding cookies with the SameSite property set.
INTERNET_FLAG_RESTRICTED_ZONE Retrieve only cookies that would be allowed if the specified URL were untrusted; that is, if it belonged to the URLZONE_UNTRUSTED zone.

ppCookies

Pointer that receives an array of INTERNET_COOKIE2 structures. The returned array must be freed by InternetFreeCookies.

pdwCookieCount

Pointer to a DWORD that receives the number of structures in the array.

Return value

Returns ERROR_SUCCESS if successful, or a system error code on failure.

Remarks

Note

WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).

Requirements

Requirement Value
Minimum supported client Windows 8.1 [desktop apps only]
Minimum supported server Windows Server 2012 R2 [desktop apps only]
Header wininet.h
Library Wininet.lib
DLL Wininet.dll

See also

HTTP Cookies

Managing Cookies

InternetSetCookieEx2

InternetFreeCookies

WinINet Functions