Updated setCookie function