• 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 prevent login by the same user from different machine

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am developing web app in struts 2 and I have requirement where if user is trying to login from different machine only one session (recent) should be allowed and all other session should invalidated.


Please help me in this regard,

Really appreciate your help.

Thanks,
Shriram.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You 'll need to keep track of which users are logged in and a reference to their session (say by putting a random number in it that you then store in the database.) That way you know if the user comes in with a new session.
 
Shriram Pandit
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne for the reply but real problem is we never know if client closes browser without properly logging out. Also do you think if it would be a overhead on database becuase every request there will database call.

Please suggest.

Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shriram Pandit wrote:Thanks Jeanne for the reply but real problem is we never know if client closes browser without properly logging out.


Right. But that problem isn't solvable.

Shriram Pandit wrote: Also do you think if it would be a overhead on database becuase every request there will database call.


You can cache in memory for X seconds rather than check every request. Or if you are only running on one clone/JVM, you can do the whole thing in memory. If not, what alternatives do you have? You could write to the file system, but that's not going to better.
 
Shriram Pandit
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne for the Reply.

Now I am trying to convince my manager to implement this functionality using database. That would be easy as well as reliable.

Will let you know once this is done. Appreciate your help.

Cheers.
 
reply
    Bookmark Topic Watch Topic
  • New Topic