📜  通过改造强制设置 cookie - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:09.539000             🧑  作者: Mango

代码示例1
String url = "https://example.com/webapi";

    OkHttp3CookieHelper cookieHelper = new OkHttp3CookieHelper();
    cookieHelper.setCookie(url, "cookie_name", "cookie_value");

    OkHttpClient client = new OkHttpClient.Builder()
            .cookieJar(cookieHelper.cookieJar())
            .build();

    Request request = new Request.Builder()
            .url(url)
            .build();