My memory is a little fuzzy, but I believe Cookie was hiding in this fortune telling machine, which promised a fortune, but instead of coins, it took cookies. Ernie saw the machine and dropped his bag of cookies in. You can hear Cookie Monster eating the cookies in his usual fashion inside, and Ernie gets his fortune which says "You will recieve a kiss from a grateful monster". Cookie then comes out and kisses Ernie and says "Thank you"
I'm not sure if that's exactly how it went, but that's the basic gist of it. Dunno what year it aired, but it was very funny as I remember it.