0

Is it possible to terminate another session that connected from different host/browser in server side?

Lets say a user has login from browserA, then trying to login again from browserB. How to invalidate his active login session in browserA at server side before register a new login session to browserB.

Scooby
  • 262
  • 1
  • 3
  • 16
  • Please be more specific. Naturally, you can call a service of the application owning the session you want to close, and have that application close the session. But I suspect you have some different scenario in mind. – TAM May 06 '16 at 07:30
  • 1
    First of all, jsf does not create or end sessions, so it is not jsf related. The container does that for you. Secondly, it might be that you try to solve a problem in a way that is not the best. Explain what the actual functional usecase is. – Kukeltje May 06 '16 at 07:48
  • @TAM and Kukeltje: I have updated the question. Thank you – Scooby May 06 '16 at 08:09
  • Why would you need to? It will end after not being used for an x-amount of time. – Kukeltje May 06 '16 at 08:11
  • @Kukeltje: Yes i know and i have set session-timeout in web.xml. But, Application only allows one active login session per user. – Scooby May 06 '16 at 08:16
  • Then block the second login. Much easier... Or write a hashmap with userid as a key and the sessionId as a value in an application scoped bean that you populate on 'session' create with the latest session ID, you can prevent further access from the previous one. – Kukeltje May 06 '16 at 08:56
  • Not block the second login, but invalidate the first session login and set new session login attribute into the second login – Scooby May 06 '16 at 09:59
  • Create a HttpSessionListener which register every session in a application-scoped Map indexed by the user id, for instance. Every time a session is created you check if there's one in that map with the same user id and, if so, invalidate it. – Jaumzera May 06 '16 at 16:04
  • Possible duplicate of [How to invalidate an user session when he logs twice with the same credentials](http://stackoverflow.com/questions/2372311/how-to-invalidate-an-user-session-when-he-logs-twice-with-the-same-credentials) – ForguesR May 10 '16 at 17:48

0 Answers0