Export (0) Print
Expand All
Expand Minimize
2 out of 4 rated this helpful - Rate this topic

InternetSetCookieEx function

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 InternetSetCookieEx(
  _In_  LPCTSTR lpszURL,
  _In_  LPCTSTR lpszCookieName,
  _In_  LPCTSTR lpszCookieData,
  _In_  DWORD dwFlags,
  _In_  DWORD_PTR dwReserved
);

Parameters

lpszURL [in]

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.

lpszCookieName [in]

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.

lpszCookieData [in]

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.

dwFlags [in]

Flags that control how the function retrieves cookie data:

ValueMeaning
INTERNET_COOKIE_EVALUATE_P3P

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.

INTERNET_COOKIE_HTTPONLY

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.

INTERNET_COOKIE_THIRD_PARTY

Indicates that the cookie being set is a third-party cookie.

INTERNET_FLAG_RESTRICTED_ZONE

Indicates that the cookie being set is associated with an untrusted site.

 

dwReserved [in]

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  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

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Wininet.h

Library

Wininet.lib

DLL

Wininet.dll

Unicode and ANSI names

InternetSetCookieExW (Unicode) and InternetSetCookieExA (ANSI)

See also

HTTP Cookies
Managing Cookies
WinINet Functions
InternetGetCookie
InternetGetCookieEx
InternetSetCookie

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.