I'm perform a http request with some cookie, My code like this:
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
cookieManager.getCookieStore().add(....);//here to set cookie
CookieHandler.setDefault(cookieManager);
// do request in following
But I can't find my cookie by fiddler. I have search many questions in stackoverflow, none of them work through. So, please help me to find the way to set cookie.
PS I don't want to use Cookie
header.
最后,我发现了问题,在我的代码中,应在任何Http操作之前调用CookieHandler.setDefault(),而应在u.openConnection()
之前u.openConnection()
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.