1

I'm creating a reactive Spring Boot project using WebFlux. I need to configure the session cookie name and path.

In a Tomcat based project it is very easy to configure the session cookie using the configuration file:

server.servlet.session.cookie.name = MYSESSIONID
server.servlet.session.cookie.path = /

If I configure these properties in the WebFlux project it doesn't affect the cookie parameters. How to do that?

rigon
  • 1,310
  • 4
  • 15
  • 37

1 Answers1

0

If you happen to be using Spring Session you can create your own bean for the WebSessionIdResolver which is what sets the name (and other attributes) of the session cookie.

@Configuration
public class CookieConfig {

    @Bean
    public WebSessionIdResolver webSessionIdResolver() {
        CookieWebSessionIdResolver resolver = new CookieWebSessionIdResolver();
        resolver.setCookieName("MYSESSIONID");
        return resolver;
    }

}

The Spring Session guides cover this in Spring Session - WebFlux with Custom Cookie.