Brought to you by the |
Cookies are a means by which, under HTTP protocol, a server or a script can maintain state information on the client workstation. The Win32 Internet functions have implemented a persistent cookie database for this purpose. Cookie functions are provided for users of Win32 Internet functions 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-*.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 its parent URLs.
Value | Description |
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. |
No call to InternetOpen is required to use this function. InternetGetCookie checks in the windows\cookies directory for cookies and searches memory for any cookies that do not have an expiration date, since these cookies are not written to any files. Rules for creating cookie files are internal to Win32 Internet functions and may change in the future.
BOOL InternetSetCookie( IN LPCSTR lpszUrlName, IN LPCSTR lpszCookieName, IN LPCSTR lpszCookieData );
Sets a cookie on the specified URL.
Creating a new cookie may cause a dialog box to appear on the screen if the appropriate registry value is set. There is no way to change the registry value from a Win32 Internet function.