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

InternetGetCookie function

Retrieves the cookie for the specified URL.

Syntax


BOOL InternetGetCookie(
  _In_     LPCTSTR lpszUrl,
  _In_     LPCTSTR lpszCookieName,
  _Out_    LPTSTR lpszCookieData,
  _Inout_  LPDWORD lpdwSize
);

Parameters

lpszUrl [in]

A pointer to a null-terminated string that specifies the URL for which cookies are to be retrieved.

lpszCookieName [in]

Not implemented.

lpszCookieData [out]

A pointer to a buffer that receives the cookie data. This parameter can be NULL.

lpdwSize [in, out]

A pointer to a variable that specifies the size of the lpszCookieData parameter buffer, in TCHARs. If the function succeeds, the buffer receives the amount of data copied to the lpszCookieData buffer. If lpszCookieData is NULL, this parameter receives a value that specifies the size of the buffer necessary to copy all the cookie data, expressed as a byte count.

Return value

If the function succeeds, the function returns TRUE.

If the function fails, it returns FALSE. To get extended error data, call GetLastError.

The following error values apply to InternetGetCookie.

Return codeDescription
ERROR_NO_MORE_ITEMS

There is no cookie for the specified URL and all its parents.

ERROR_INSUFFICIENT_BUFFER

The value passed in lpdwSize is insufficient to copy all the cookie data. The value returned in lpdwSize is the size of the buffer necessary to get all the data.

ERROR_INVALID_PARAMETER

One or more of the parameters is invalid.

The lpszUrl parameter is NULL.

 

Remarks

InternetGetCookie does not require a call to InternetOpen. InternetGetCookie checks in the windows\cookies directory for persistent cookies that have an expiration date set sometime in the future. InternetGetCookie also searches memory for any session cookies, that is, cookies that do not have an expiration date that were created in the same process by InternetSetCookie, because these cookies are not written to any files. Rules for creating cookie files are internal to the system and can change in the future.

As noted in HTTP Cookies, InternetGetCookie does not return cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.

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

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Wininet.h

Library

Wininet.lib

DLL

Wininet.dll

Unicode and ANSI names

InternetGetCookieW (Unicode) and InternetGetCookieA (ANSI)

See also

HTTP Cookies
Managing Cookies
WinINet Functions
InternetGetCookieEx
InternetSetCookie
InternetSetCookieEx

 

 

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