• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to invalidate a session in one browser when the same user login from any other browser?

 
Greenhorn
Posts: 20
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,

Consider i have a user with User Id : - anshul@gmail.com .Now i am loggin with this id in firefox. At the same time i am open other browser IE and login again with the same id.

I need when the try to login with the same id in diffrent browser the session of first browser will removed automatically. So in this case user can remain logged in with IE. not FireFox.


Please help me ..

Thanks
 
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to maintain a mapping of Sessions to User's.

When a new session is being created for a user, if that user already has a session, invalidate the first session.
 
Anshul K Jain
Greenhorn
Posts: 20
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can you please provide me a sample code for it .
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Do you use any kind of Security framework? I know you can set Spring Security to do this in its configuration.
If not then as Chinna said, create a map of users to session IDs. If a user logs in and is already in the map, then invalidate the previous session and add their new one, otherwise add them to the map.

Sean
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to use HttpSessionListener for this functionality.
 
reply
    Bookmark Topic Watch Topic
  • New Topic