Same session and session ID for different subdomains in Grails project - How can I do that?
- by fluxon
I am currently working on a project that supports multiple languages. In order to be seo friendly, I am trying to redirect users subdomains corresponding to their locale (or their preferred language).
I.e., my projects's url is mydomain.com and I work with the subdomains en.mydomain.com, es.mydomain.com, de.mydomain.com, fr.mydomain.com ... you get the idea. All subdomains are served by the same grails app for now.
What happens is that my grails project maintains different sessions (as seen by the session ids) for every single subdomain, hence information is lost, when a user switches between languages. I had not forseen that. :(
How can I explicitly set the session identifier? I would like it to be based on just mydomain.com.
I got the hint that Apache Tomcat offers something like
<Context sessionCookiePath="/" sessionCookieDomain=".mydomain.com">
, but that does not help for the devel environment etc.
Any hints? Have you tried storing session information in the DB? This is sometimes used for load-balancing purposes and might help here as well?!
Help is highly appreciated (as always)! Cheers!