updated cookie function