Cookies in an ISAPI Extension DLL

I was designing an ISAPI .dll for use on our website, and quickly discovered
what little information is available regarding the use of cookies on an MFC
server side ISAPI extension. For login purposes, the cookies were absolutely
essential. Hopefully this code will save somebody the R&D I had to go through…

First of all, let’s talk about how cookies work. Cookies are basically just
variables, and can be VERY useful in state management, user identification,
etc. Cookies are set and retrieved via the HTTP headers. To create a cookie,
the server includes a "Set-Cookie" command in the header. After a
cookie is set, the client will pass the cookies and their values to the server
in the header of every HTTP request. More details of what to send and what is
received can be found at

Below find source code for a CCookie class, with member functions GetCookie,
SetCookie, and EnumCookies; as well as a sample ISAPI project.

To use the sample project, simply build it, and place ISAPICookies.DLL in your
WWWROOT directory (make sure you have execute access enabled for that directory);
then direct your browser to http://localhost/ISAPICookies.DLL

Feel free to contact me with any questions or comments.


Download demo project – 14 Kb

More by Author

Must Read