I use a function to get all logged session below:

List<Object> allPrincipals = sessionRegistry.getAllPrincipals();
List<Whois> whoisList = new ArrayList<Whois>();
for (Object principal : allPrincipals) {
    List<SessionInformation> siList = sessionRegistry.getAllSessions(principal, false);         
    for (SessionInformation si : siList) {
        User u = (User)si.getPrincipal();
        Whois w = new Whois();
        w.setSessionId(si.getSessionId());
        w.setExpired(false);
        w.setLastRequest(this.getTimestamp(si.getLastRequest()));
        w.setLogged(true);
        w.setUsername(u.getUsername());
        whoisList.add(w);
    }
}

Compared with authentication.getDetails(), but the sessionid is different.

public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {

    HttpSession session = request.getSession(false);
    if (session != null) {
        // 將 Object 轉換成 Map
        ObjectMapper oMapper = new ObjectMapper();
        Map<String,String> authDetail = oMapper.convertValue(authentication.getDetails(),Map.class);
        Whois whois = sysService.setWhoIsOnline( authDetail , authentication.getName());
    }

}

why? Is there any other way to get the same sessionid? Any help would be greatly appreciated

Comment From: snicoll

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

Comment From: polinwei

Thanks for your suggestion.