HttpURLConnection设置Cookie:
参考自:如何在HttpURLConnection设置Cookie(Finn_ZengYuan博客) - Finn_ZengYuan - 博客园
HttpURLConnection con= (HttpURLConnection) url.openConnection();
con.setRequestProperty("Cookie", "data");
其中的“cookie”需要和服务器端设置的“Cookie”保持一致(key保持一致)
--------------------------------------------------------------------------------------------------------------------------------
OkHttpClient设置Cookie(在Request里添加):
参考自:android okhttp使用cookie请求_谢岩的博客-优快云博客
Request request = new Request.Builder()
.url(url)
.header("Cookie", "xxx")
.build();