added readCookie function.