[This documentation is preliminary and is subject to change.]
Applies to: desktop apps only
Calls the standard InternetSetCookieEx from a higher-integrity user context. Creates a cookie with a specified name that is associated with a specified URL.
HRESULT IESetProtectedModeCookie( _In_ LPCWSTR lpszURL, _In_ LPCWSTR lpszCookieName, _In_ LPWSTR pszCookieData, _In_ DWORD dwFlags );
A pointer to a null-terminated string that contains the URL for which the cookie should be set.
A pointer to a null-terminated string that contains the name to associate with this cookie. If this pointer is NULL, then no name is associated with the cookie.
A pointer to a null-terminated string that contains the data to be associated with the new cookie.
Flags that control how the function sets cookie data:
INTERNET_COOKIE_THIRD_PARTY (0x10)
Indicates that the cookie being set is a third-party cookie.
INTERNET_FLAG_RESTRICTED_ZONE (0x00020000)
Indicates that the cookie being set is associated with an untrusted site.
If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
To create a persistent cookie, add an expires name/value pair to the cookie data. The format of the value must be DAY, DD-MMM-YYYY HH:MM:SS GMT. DAY is a three-letter abbreviation for the day of the week, DD is the day of the month, MMM is a three-letter abbreviation for the month, YYYY is the year, and HH:MM:SS is the time of day in 24-hour format.
expires
DAY, DD-MMM-YYYY HH:MM:SS GMT
DAY
DD
MMM
YYYY
HH:MM:SS
The following example shows how to use the IESetProtectedModeCookie method to create a persistent cookie in the protected mode cookie store.
HRESULT hr = E_FAIL; TCHAR szTime[100]; TCHAR szCookieVal[MAX_PATH]; COleDateTime oDate; SYSTEMTIME systime; SecureZeroMemory(szCookieVal, sizeof(TCHAR) * MAX_PATH); oDate = COleDateTime::GetCurrentTime(); //set expiry to a day. oDate+= COleDateTimeSpan(1, 0, 0, 0); if (oDate.GetAsSystemTime(systime)) { if (InternetTimeFromSystemTime(&systime, INTERNET_RFC1123_FORMAT, szTime, MAX_PATH)) { if (SUCCEEDED(StringCchPrintf(szCookieVal, MAX_PATH,L"%s;expires=%s", L"CookieValue",szTime))) { hr = IESetProtectedModeCookie(L"http://contoso.com", L"CookieName", szCookieVal, NULL); if (hr != S_OK) { hr = HRESULT_FROM_WIN32(GetLastError()); } } } } return hr;
Minimum supported client
Minimum supported server
Product
Header
Library
DLL
Build date: 3/14/2012