This example shares with you the method of java using cookies to determine user login status for your reference. The specific content is as follows
1. Determine whether to log in
public boolean isLogin() { Set<Cookie> cookies = this.browser.getCookies(); String JSESSIONIDID = "JSESSIONID"; String sessionIdID = "sessionId"; String loginID = "login"; String JSESSIONIDIDValue = ""; String sessionIdValue = ""; String loginValue = ""; for (Cookie c:cookies) { logger.info(c.getName() + ": " + c.getValue()); if (c.getName().equals(JSESSIONIDID)) { JSESSIONIDIDValue = c.getValue(); } else if(c.getName().equals(sessionIdID)) { sessionIdValue = c.getValue(); } else if (c.getName().equals(loginID)) { loginValue = c.getValue(); } } if ( JSESSIONIDIDValue.equals(sessionIdValue) & loginValue.equals("login")) { return true; } else { return false; } }2. Page login cookies
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.