65.9K
CodeProject is changing. Read more.
Home

Cookie Spy

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.85/5 (14 votes)

Mar 4, 2001

viewsIcon

205680

downloadIcon

5158

Creating a CookieSpy explorer bar with ATL

  • Download source files - 44 Kb
  • Download dll - 64 Kb
  • Sample Image - CookieSpy.gif

    Introduction

    CookieSpy is a custom explorer bar. This extension was created for the monitoring of cookie activity and for the possibility to add and edit cookies. I used VC++ 6.0 (SP4) and ATL.

    Implementation.

    1. At first, every IE band object must implement a couple interfaces:
    - IDeskBand
    - IObjectWithSite
    I wrote a template class DeskBandImpl<> to implement all the IE necessary routines.

    2. Second, the band object must add to the registry the appropriate records to the "Component Categories" hive. I registered for CATID_InfoBand and CATID_CommBand categories. Certainly, you can use only one placement for band: vertical or horizontal at the same time.

    3. Next, when IE calls IObjectWithSite::SetSite method, the main objectives are:
    - to create a band window.
    - to advise DWebBrowserEvents2 event sink interface for receiving event notifications from a explorer

    4. CookieSpy::OnCreate method objectives:
    - to create MSHTML control for displaying HTML page from resource
    - to set external dispatch

    5. By processing events: BeforeNavigate2, DocumentComplete, NavigateComplete2, I try to update the cookie's information for the current document:
    - to parse cookie string
    - to update a main html page

    Cookie Edit Dialog

    6. Also the user can add and edit the cookie. If the cookie was stored on the hard disc, I try to find the cookie's file in cookie's folder for determining a expire date and domain\path info otherwise (in case lack of such file) I suggest that it's the session cookie. Then with help InternetSetCookie API I create a cookie for the specified URL.

    Environment.

    I tested this band under Win2k and IE 5.0 only

    Acknowledgments.

    Thanks a Neeraj Srivastava for his article "Implementing Web Browser Band Using ATL HTML Control"

    History

    12 Oct 2001 - New download files: These solve trouble with IE.5.5\6.0 and CookieSpy plug-ins.