public static boolean requestHasSessionCookie(final HttpServletRequest request) {
        if (request == null || request.getCookies() == null) {
            return false;
        }

        // Find out if we have a session cookie
        return Arrays
                .stream(request.getCookies())
                .anyMatch(cookie ->
                        cookie.getName().equalsIgnoreCase(STROOM_SESSION_ID) ||
                        cookie.getName().equalsIgnoreCase(JSESSIONID));
    }
Set the userIdentity on the session, creating the session as required
stroom-security/stroom-security-common-impl/src/main/java/stroom/security/common/impl/UserIdentitySessionUtil.java