Updated get cookie function