Brought to you by the
RFC INDEX PAGE
Google
 


Microsoft Win32 Internet Programmer's Reference


Cookie Functions

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.

InternetGetCookie

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.

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 the buffer necessary to copy all the cookie 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.

InternetSetCookie

BOOL InternetSetCookie(
    IN LPCSTR lpszUrlName,
    IN LPCSTR lpszCookieName,
    IN LPCSTR lpszCookieData
);

Sets a cookie on the specified URL.

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.

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.

© 1996 Microsoft Corporation