add cookies function to handle cookies