reduce cookie tracking (6/6): count cookies

add an efficient cookie counting function

Change-Id: Iec879d797ed22cf47509d3aba0928e699ee96410