Cookies are a means by which, under HTTP protocol, a server or a script can maintain state information on the client workstation. WinInet has implemented a persistent cookie database for this purpose. Cookie functions are provided for users of WinInet in order to set cookies into, and access them from, the cookie database. The caller of these functions should be familiar with cookies as outlined in ftp://ds.internic.net/internet-drafts/draft-ietf-http-state-mgmt-01.txt. Please note that the implementation of these functions is evolving; be cautious when using them.
BOOL InternetGetCookie(
IN LPCSTR lpszUrlName,
IN LPCSTR lpszCookieName,
OUT LPSTR lpszCookieData,
IN OUT LPDWORD lpdwSize
);
Returns cookies for the specified URL and all it's parent URLs.
- Returns TRUE if successful or FALSE otherwise. To get the specific error value, call GetLastError. The following error values apply to InternetGetCookie:
Value
| Description
|
ERROR_FILE_NOT_FOUND
| There is no cookie for the specified URL and all it's 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 buffer necessary to get all the data.
|
- lpszUrlName
- Address of a string that contains the URL to get cookies for.
- lpszCookieName
- Address of the name of the cookie to get for the specified URL. This has not been implemented in this release.
- lpszCookieData
- Address of the buffer that receives the cookie data. This value can be NULL.
- lpdwSize
- Address of a variable that specifies the size of the lpszCookieData buffer. If the function succeeds, the buffer receives the amount of data copied to the lpszCookieData buffer. If lpCookieData is NULL, this parameter receives a value that specifies the size of buffer necessary to copy all the cookie data.
BOOL InternetSetCookie(
IN LPCSTR lpszUrlName,
IN LPCSTR lpszCookieName,
IN LPCSTR lpszCookieData
);
Sets a cookie on the specified URL.
- Returns TRUE if successful or FALSE otherwise. To get the specific error code, call GetLastError.
- lpszUrlname
- Address of a null-terminated string that specifies the URL for which the cookie should be set.
- lpszCookieName
- Address of a string that contains the name to associate with the cookie. If this parameter is NULL, no name is associated with the cookie. This parameter is not implemented in this release and should be set to NULL.
- lpszCookieData
- Address of the actual data to associate with the URL.