private void configureCookies(String url) {

    final CookieManager cookieManager = CookieManager.getInstance();

    String cookieHeader = cookieManager.getCookie(url);

    if (cookieHeader != null) {

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cookieManager.removeAllCookies(null);
      } else {
        cookieManager.removeAllCookie();
      }

      // We want to always enter in a not-logged-in state.  If the webview has a cookie indicating
      // it has logged in then it will bypass login and go to the .com site.  Remove that cookie.
      // Also, with CookieManager there is no direct way to remove a cookie.  We just iterate the
      // full set and only add back the cookies we want.
      String[] cookies = cookieHeader.split(";");
      for (String cookie : cookies) {
        if (!cookie.trim().startsWith(ACCESS_TOKEN_COOKIE + '=')) {
          cookieManager.setCookie(url, cookie);
        }
      }
    }

    // Add the small view cookie.
    // TODO: In a future release, determine the device size (phone v. tablet) and set the correct
    // cookie value for size
    cookieManager.setCookie(url, "idl_icc=s");

    Log.e(TAG, "configureCookies cookie manager : " + cookieManager.getCookie(url));
  }