How to set the domain and cookie path using Spring boot

In Tomcat, we can do this as follows:

<Context useHttpOnly="true" sessionCookiePath="/"sessionCookieDomain=".XXXX.com"/> 

I want to share a cookie for a second level domain using Spring Boot, how to do this?

+6
source share
2 answers

Server settings that Spring boot inserts are available as application properties ( specified here in the # EMBEDDED SERVER CONFIGURATION section and in the server.session.cookie.* Namespace).

The equivalent of Tomcat configuration above should be:

 # properties in /src/resources/application.properties server.session.cookie.domain=.XXXX.com server.session.cookie.http-only=true server.session.cookie.path=/ 
+8
source

My solution was to define a CookieSerializer bean and provide a domain template that matches my setting.

Example: Spring Session - Custom Cookie

0
source

All Articles