fix cookie function to cache active tab