Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function retrieves the cookie for the specified URL.

Syntax

BOOL InternetGetCookie(
  LPCTSTR 
lpszUrl,
  LPCTSTR 
lpszCookieName, 
  LPSTR
 lpCookieData, 
  LPDWORD
 lpdwSize
);

Parameters

lpszUrl

[in] Address of a string that contains the URL to get cookies for.

lpszCookieName

[in] Address of a string that contains the name of the cookie to get for the specified URL. This has not been implemented in this release.

lpCookieData

[out] Address of the buffer that receives the cookie data. This value can be NULL.

lpdwSize

[in, out] When the function is called, the address of an unsigned long integer variable that specifies the size of the lpszCookieDatabuffer. On return, if the function succeeds, the buffer receives the amount of data copied to the lpszCookieDatabuffer. If lpszCookieDatais NULL, this parameter receives a value that specifies the size of the buffer necessary to copy all the cookie data.

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

This function does not require a call to InternetOpen. To retrieve cookies, it checks for both session cookies and persistent 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. Persistent cookies, which have an expiration date, are stored in the location specified in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Foldersregistry key. The default location is Windows\Profiles\Guest\Cookies. Because the rules for creating cookie files are internal to WinInet functions and are subject to change, your application should always call InternetGetCookie, rather than attempt to access cookie files directly.

Requirements

Header wininet.h
Library wininet.lib
Windows Embedded CE Windows CE 2.12 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also