IEGetProtectedModeCookie function

Calls the standard InternetGetCookieEx from a higher-integrity user context. Retrieves the cookie data from the protected mode cookie store.

Syntax

HRESULT IEGetProtectedModeCookie(
  _In_    LPCWSTR lpszURL,
  _In_    LPCWSTR lpszCookieName,
  _Inout_ LPWSTR  pszCookieData,
  _Inout_ DWORD   *pcchCookieData,
  _In_    DWORD   dwFlags
);

Parameters

lpszURL [in]

A pointer to a null-terminated string that contains the URL associated with the cookie to be retrieved.

lpszCookieName [in]

A pointer to a null-terminated string that contains the name of the cookie to retrieve. This name is case-sensitive.

pszCookieData [in, out]

A pointer to a buffer to receive the cookie data.

pcchCookieData [in, out]

A pointer to a DWORD variable.

dwFlags [in]

A flag that controls how the function retrieves cookie data. This parameter can be one of the following values.

d (INTERNET_COOKIE_THIRD_PARTY)

Retrieves only third-party cookies if policy explicitly allows all cookies for the specified URL to be retrieved.

d (INTERNET_FLAG_RESTRICTED_ZONE)

Retrieves only cookies that would be allowed if the specified URL were untrusted; that is, if it belonged to the URLZONE_UNTRUSTED zone.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

The following example shows how to use the IEGetProtectedModeCookie method to read a cookie from the protected mode cookie store.

TCHAR szActualCookie [MAX_PATH];
HRESULT hr = E_FAIL;
DWORD dwSize = MAX_PATH;
    
if (m_pszURL)
{
  hr = IEGetProtectedModeCookie(L"https://contoso.com", L"CookieName", 
                                szActualCookie, &dwSize, NULL);

  if (hr != S_OK)
  {
    hr = HRESULT_FROM_WIN32(GetLastError());
  }
}
return hr;      

Requirements

Minimum supported client

Windows XP with SP2

Minimum supported server

Windows Server 2003

Product

Internet Explorer 8

Header

Iepmapi.h

Library

Iepmapi.lib

DLL

Ieframe.dll

See also

Reference

IESetProtectedModeCookie

Conceptual

Protected Mode Broker Functions

Other Resources

InternetGetCookieEx

Understanding and Working in Protected Mode Internet Explorer