I have a Java 8 web app running on a Tomcat 8 container that was deployed using AWS Elastic Beanstalk to an EC2 instance. I then configured Route 53 to point myapp.com
to the Elastic Beanstalk endpoint as an alias, and did the same with www.myapp.com
.
The problem is that when I login with either of them, the session is not shared with the other one. For example, if I login with myapp.com
, and then try to access www.myapp.com
, I'm being asked to login again. This problem is reproducible vice-versa and with the logout function too.
I've read this answer explaining the issue and while I understand the theory, I'm unsure on how to actually implement this. I tried pointing www.myapp.com
directly to myapp.com
as an alias on Route 53. I also tried configuring EB to use an Elastic Load Balancer and checked the Sticky Sessions option.
Is this something that can be configured on AWS or do I need to configure my code to accommodate this? An example would be really helpful. The application is a standard Enterprise Java web app with JSP and uses Spring Security for authentication.