Search code examples
javaspringspring-session

Disable multiple session support in Spring Session


I would like to use Spring Session in an xml-config-based project, but without support for multiple sessions (user-logins) in the same browser window.

Can that be disabled? If yes, how?


Solution

  • As per CookieHttpSessionStrategy#setSessionAliasParamName javadoc:

    Sets the name of the HTTP parameter that is used to specify the session alias. If the value is null, then only a single session is supported per browser.

    So with Spring XML config this translates to:

    <bean class="org.springframework.session.web.http.CookieHttpSessionStrategy">
        <property name="sessionAliasParamName">
            <null/>
        </property>
    </bean>