I need to share session variables across multiple war files. My project has 3 wars (lets call them war1, war2, war3) and once login is completed in war1, there are redirection links for war2 and war3 files. I need to share the same session username across all the three wars.
Currently I have used request.getSession().getServletContext().getContext("rootContextName").getAttrubute("sessionName") in war2 and war3 to get the sessionName from war1. But I am not sure if this is the right way to go about it.
I need to know if there is any other way possible to achieve the same.
Thank you in advance!
Edit: When I am logging in from war1 and traversing to war2 from browser1, the session values are set properly and I can access them. But when I am using the same URL of war2 in browser2, I am still able to see the session values set and able to get them. I dont want this cross-browser session sharing. Any suggestions are welcome! Thanks!