Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
InternetSetCookieExA function (wininet.h)
The InternetSetCookieEx function creates a cookie with a specified name that is associated with a specified URL. This function differs from the InternetSetCookie function by being able to create third-party cookies.
Syntax
DWORD InternetSetCookieExA(
[in] LPCSTR lpszUrl,
[in] LPCSTR lpszCookieName,
[in] LPCSTR lpszCookieData,
[in] DWORD dwFlags,
[in] DWORD_PTR dwReserved
);
Parameters
[in] lpszUrl
Pointer to a null-terminated string that contains the URL for which the cookie should be set.
If this pointer is NULL, InternetSetCookieEx fails with an ERROR_INVALID_PARAMETER error.
[in] lpszCookieName
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.
[in] lpszCookieData
Pointer to a null-terminated string that contains the data to be associated with the new cookie.
If this pointer is NULL, InternetSetCookieEx fails with an ERROR_INVALID_PARAMETER error.
[in] dwFlags
Flags that control how the function retrieves cookie data:
| Value | Meaning |
|---|---|
|
If this flag is set and the dwReserved parameter is not NULL, then the dwReserved parameter is cast to an LPCTSTR that points to a Platform-for-Privacy-Protection (P3P) header for the cookie in question. |
|
Enables the retrieval of cookies that are marked as "HTTPOnly".
Do not use this flag if you expose a scriptable interface, because this has security implications. If you expose a scriptable interface, you can become an attack vector for cross-site scripting attacks. It is utterly imperative that you use this flag only if they can guarantee that you will never permit third-party code to set a cookie using this flag by way of an extensibility mechanism you provide. Version: Requires Internet Explorer 8.0 or later. |
|
Indicates that the cookie being set is a third-party cookie. |
|
Indicates that the cookie being set is associated with an untrusted site. |
[in] dwReserved
NULL, or contains a pointer to a Platform-for-Privacy-Protection (P3P) header to be associated with the cookie.
Return value
Returns a member of the InternetCookieState enumeration if successful, or FALSE if the function fails. On failure, if a call to GetLastError returns ERROR_NOT_ENOUGH_MEMORY, insufficient system memory was available.
Remarks
Note
The wininet.h header defines InternetSetCookieEx as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows XP [desktop apps only] |
| Minimum supported server | Windows Server 2003 [desktop apps only] |
| Target Platform | Windows |
| Header | wininet.h |
| Library | Wininet.lib |
| DLL | Wininet.dll |
See also
Feedback
Was this page helpful?
