Skip to content

Support configuring Spring Session's session cookie using ServerProperties #10371

@vpavic

Description

@vpavic

Spring Session has support for configuring session cookie using Servlet API's SessionCookieConfig, so one would expect it would be possible to configure session cookie using Boot's ServerProperties. This however does not work due to following reasons.

The problem is that Spring Session's CookieSerializer is configured in SpringHttpSessionConfiguration while Boot's customization of SessionCookieConfig with ServerProperties is done in DefaultServletWebServerFactoryCustomizer.SessionConfiguringInitializer and happens after Spring Session has been initializing.

The problem can be observed using spring-boot-sample-session with configuration property server.session.cookie.name=sid, and breakpoints set in org.springframework.boot.autoconfigure.web.servlet.DefaultServletWebServerFactoryCustomizer.SessionConfiguringInitializer#configureSessionCookie and org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration#createDefaultCookieSerializer.

Related to #7141.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions