开发者

Reset JSessionID on URL modification

开发者 https://www.devze.com 2023-03-23 06:15 出处:网络
I am currently Internationalising a website, and have hit some issues around the jsessionIDs. I am using Apache web server that load balances across multiple JBoss app servers via mod_jk.

I am currently Internationalising a website, and have hit some issues around the jsessionIDs. I am using Apache web server that load balances across multiple JBoss app servers via mod_jk.

When I hit the site on the default GB URL, the jsessionID is correctly created on the dedicated jboss app server. e.g. www.mysite.com create session on GB_Jboss.

When I update the URL to www.mysite.com/fr, I want a new jsessionID to be created on FR_JBoss.

When I update the URL to www.mysite.com/us, I want a new jsessionID to be created on US_JB开发者_如何学JAVAoss.

However, each time I update the URL, it always displays the original jsessionID.

I hope this makes sense? Any ideas how I can get this to work via Apache? Or id this a load balancing issue at the load balancer?


Curious to know why you want to have new session for different URI. Anyway, couple of options I can think of:

  1. Add an entry in the cookie for the URI you generated the session for. For example, if yoursite/fr has got the session first, add that to the client cookie. On each request, you can use filter to inspect whether the URI is different from the one specified in the cookie. if yes, invalidate that session and let the new one be created for the user.
  2. Maintain a singleton HashMap on the server side that has site URI and session ID mapping. If the site URI does not match with session ID on each request - invalidate session. The downside of this approach is that the HashMap needs to be replicated across all nodes in the cluster for it to work properly after a fail over to another server.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号