Connection.Response res = Jsoup.connect("http://www.example.com/login.php") .data("username", "myUsername", "password", "myPassword") .method(Method.POST) .execute(); Document doc = res.parse(); String sessionId = res.cookie("SESSIONID"); // you will need to check what the right cookie name is
/** * Sets the application language cookie. * <p> * If the language does not match a registered language or language * component an exception is thrown. * </p> * * @param language * @param routeContext * @throws PippoRuntimeException */ public void setLanguageCookie(String language, RouteContext routeContext) { String lang = getLanguageOrDefault(language); if (lang.equals(language)) { Cookie cookie = generateLanguageCookie(language); routeContext.getResponse().cookie(cookie); } else { throw new PippoRuntimeException("'{}' is not a registered language!", language); } }
@Override public void addResponseCookie(Cookie cookie) { getResponse().cookie(cookie.getPath(), cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getMaxAge(), cookie.isSecure() ); javax.servlet.http.Cookie addedCookie = getResponse().getCookie(cookie.getName()); addedCookie.setHttpOnly(cookie.isHttpOnly()); addedCookie.setComment(cookie.getComment()); }
Connection.Response res = Jsoup.connect("http://www.cybernations.net/login.asp") .data("Username", "myUsername", "Validate_Password", "myPassword") .method(Method.POST) .execute(); Document doc = res.parse(); String sessionId = res.cookie("ASPSESSIONIDAAACSTQB");
Connection.Response res = Jsoup.connect(loginUrl).execute(); String sessionId = res.cookie("sessionId"); Document doc = res.parse();