Support for multiple domains when writing the session cookie
Hi Spring Team,
I came up to a situation where I need to issue the session cookie for 2 different domains.
Didn't find that in docs neither in code, since org.springframework.boot.web.servlet.server.Session has only 1 Cookie and org.springframework.session.web.http.DefaultCookieSerializer.writeCookieValue() seems to be called only once and also writes to response once.
Is there a way to do it (maybe I'm missing smth)? Or do you plan to have it soon?
For reference, I found these issues that seem to be diff but related #1323 #297 #299 #162 #955
@rwanderc
You can call org.springframework.session.web.http.DefaultCookieSerializer.setDomainNamePattern method and pass it a string like
^(domain1\.example\.com|domain2\.example\.com)$
This will make it extract domain from request, test against provided RegExp pattern, select one of the two values (domain1.example.com or domain2.example.com) and set corresponding domain value for session cookie.