Skip to content

Latest commit

 

History

History
125 lines (81 loc) · 4.8 KB

nf-wininet-internetsetcookiew.md

File metadata and controls

125 lines (81 loc) · 4.8 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:wininet.InternetSetCookieW
InternetSetCookieW function (wininet.h)
Creates a cookie associated with the specified URL. (InternetSetCookieW)
InternetSetCookie
InternetSetCookie function [WinINet]
InternetSetCookieW
_win32_internetsetcookie
wininet.internetsetcookie
wininet/InternetSetCookie
wininet/InternetSetCookieW
wininet\internetsetcookie.htm
wininet
1b1ca72e-9c74-4e94-86a9-6fee12c83933
12/05/2018
InternetSetCookie, InternetSetCookie function [WinINet], InternetSetCookieA, InternetSetCookieW, _win32_internetsetcookie, wininet.internetsetcookie, wininet/InternetSetCookie, wininet/InternetSetCookieA, wininet/InternetSetCookieW
wininet.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
InternetSetCookieW (Unicode) and InternetSetCookieA (ANSI)
Wininet.lib
Wininet.dll
Windows
19H1
InternetSetCookieW
wininet/InternetSetCookieW
c++
APIRef
kbSyntax
DllExport
Wininet.dll
InternetSetCookie
InternetSetCookieA
InternetSetCookieW

InternetSetCookieW function

-description

Creates a cookie associated with the specified URL.

-parameters

-param lpszUrl [in]

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

-param lpszCookieName [in]

Pointer to a null-terminated string that specifies the name to be associated with the cookie data. If this parameter is NULL, no name is associated with the cookie.

-param lpszCookieData [in]

Pointer to the actual data to be associated with the URL.

-returns

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

-remarks

Cookies created by InternetSetCookie without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.

Creating a new cookie might cause a dialog box to appear on the screen asking the user if they want to allow or disallow cookies from this site based on the privacy settings for the user.

Caution  InternetSetCookie will unconditionally create a cookie even if “Block all cookies” is set in Internet Explorer. This behavior can be viewed as a breach of privacy even though such cookies are not subsequently sent back to servers while the “Block all cookies” setting is active. Applications should use InternetSetCookieEx to correctly honor the user's privacy settings.

For more cookie internals, see http://blogs.msdn.com/ieinternals/archive/2009/08/20/WinINET-IE-Cookie-Internals-FAQ.aspx.

 

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

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

Note

The wininet.h header defines InternetSetCookie as an alias which 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 not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

HTTP Cookies

InternetGetCookie

InternetGetCookieEx

InternetSetCookieEx

Managing Cookies

WinINet Functions