Download Now  Sourceforge Project Page

About nCookieReader

nCookieReader is a very small C# .NET library for reading web browser cookie files. nCookieReader is in the beta stages right now and was originally written to be used in another project called Page Scavenger. Page Scavenger needed to be able to read the cookies for a web site from the browsers' cookie files and since there didn't appear to be any .NET libraries out there for doing it, nCookieReader was born.

nCookieReader is in the early stages of development. It can be used to read cookies from Firefox and Internet Explorer web browsers currently. At the very least, I expect to add support for Opera as well and possibly other browsers if there's any demand for it.

Using nCookieReader

nCookieReader is easy to use because my needs were simple. You cannot save cookies, you can only read them (hence the name).

Here's an example of how you would get the IE browser cookies for, for example:

ICookieReader cookieReader = CookieReaderFactory.GetCookieReader(CookieReaderType.InternetExplorer)
CookieContainer container = cookieReader.GetCookieContainer("");

And voila, you're done. Attach the CookieContainer to your HttpWebRequest object and you're in business.

Currently there are two CookieReaderTypes: InternetExplorer and Firefox. There's a second CookieReaderFactory.GetCookieReader() method that's currently the only one usable for Firefox. It takes, as a second parameter, the path and filename of the cookies.txt file. I plan on adding support to the above GetCookieReader() method to return the default profile's cookie.txt, but for the moment, you have to specify the cookie.txt file since Firefox supports multiple profiles and this met my needs at the time.

If you look at the code, you'll see the CookieReaderFactory is pretty basic and ICookieReader only supports the one method, GetCookieContainer().

In addition to the support for Firefox using the first GetCookieReader method, I also plan to add support for the Opera web browser. Beyond that, I don't have any grand plans for nCookieReader. It's meant to be a simple library to fulfill a simple need, very simply.

If you're interested in adding features, please let me know, I'm happy to have contributions. In particular, if you want to contribute the code for reading Opera cookies, that would be nice, since I don't have Opera yet. Please report bugs in the bug tracker and feature requests in the feature tracker. Logo