fix cookie function error