We have multiple applications being hosted on the same domain. For all apps, the session is stored in a cookie which is on the same domain as well.
Now if a user can access more than 1 app from the same browser, the he/she are being logged out of the other apps.
Can someone guide me on how we can design the apps in such a way that session information is not overridden across multiple apps?
2
Answers
It turns out that this cookie is set from the server and we could control it from each application by configuring this extra property:
server.servlet.session.cookie.name=Your_custome_name
Cookie name is unique across all apps and across all environments.
This is tested and working.
Firstly, I’d like to mention that running multiple apps like this under the
one
domain should be discouraged since it could lead to security issues if one of these apps were compromised. One should use subdomains for this e.g.,<app1>.<domain>
then<app2>.<domain>
If you are still on this and want to achieve what you asked for, you must use the
paths
while setting cookies. As outlined on MDN web docshttps://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie