Windows Mobile 6.5
A version of this page is also available for

This function creates a cookie associated with the specified URL. This function extends the functionality of InternetSetCookie by identifying third-party cookies.

BOOL InternetSetCookieEx( 
  LPCTSTR lpszUrl,
  LPCTSTR lpszCookieName,
  LPCTSTR lpszCookieData,
  DWORD dwFlags,
  DWORD_PTR dwReserved


[in] Pointer to a null-terminated string that specifies the URL for which the cookie should be set.


[in] Pointer to a string that contains the name to associate with the cookie data. If this parameter is NULL, no name is associated with the cookie.


[in] Pointer to the actual data to associate with the URL.


[in] Must be set to INTERNET_COOKIE_THIRD_PARTY. In Windows Embedded CE, any other value will cause function to return FALSE with the error message set to ERROR_INVALID_PARAMETER.


[in] Reserved. Must be set to zero.

Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError.

As with InternetSetCookie, InternetSetCookieEx creates a cookie that is associated with a particular URL. In addition, InternetSetCookieEx verifies that the cookie is a third-party cookie and checks the policy to see if third-party cookies are allowed.

Creating a new cookie may cause a dialog box to appear on the screen if the appropriate registry value, AllowCookies, is set. There is no way to change the registry value from a WinInet function.

Persistent cookies, which have an expiration date, are stored in the location specified in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key. The default location is Windows\Profiles\Guest\Cookies. Session cookies, which do not have an expiration date, are stored in memory and are available only to the process in which they were created.

Windows Embedded CEWindows CE .NET 4.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions