Microsoft & .NETVisual C#Cookies in an ISAPI Extension DLL

Cookies in an ISAPI Extension DLL

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

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 http://www.netscape.com/newsref/std/cookie_spec.html

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.

Downloads

Download demo project – 14 Kb

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories