• Post Reply Bookmark Topic Watch Topic
  • New Topic

logout problem  RSS feed

 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Java code insert one value e.g. 1 into the database when user become online and when logout then its updating it as 0

The problem is that some users don't logout or turn off their computer. What'll be the solution in this case?

Thanks & best regards
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session listener?

Are you even writing a web application? If so, there's a forum for that. If not, we'll need more information.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For web applications, session listeners are the way to go. For non-web applications, a shutdown hook (see the Runtime class) would be the best option. Keep in mind that the latter is not guaranteed to run; it will only run if the application is closed nicely. If the JVM is forcefully terminated somehow (which the operating system will eventually down when shutting down) it will not run.
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Session Listener example...
 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Farakh khan wrote:The problem is that some users don't logout or turn off their computer. What'll be the solution in this case?


Is "this case" the case where they just leave the application running and go away for lunch, or two weeks holiday, or something? Why is that a problem? (If that is indeed the problem...)
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way you can record the latest traffic from a particular user and set a time-out?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!