Change addCookie API, close #1398