Fixed getCookies function