Improved addCookie method to avoid adding cookies with the same name