You could do it in another way though.
Just keep track of the users login and logout time (that way you might even check session lengths for future reference or statistics) by placing this information in a database table.
So as soon as your user logs in you check in the database whether a user with this userID is still logged in, by checking the last entry with this userID and checking whether or not a loggedout time has been filled in. If not then the user is still logged in and either needs to be logged out. So, you set it's loggedout time to that time...
As soon as the user that was logged in now changes pages you check whether or not he is logged in..in this case he is not, as he has already been logged out, and so you direct that user to the login page.
My only real problem with this is that if you have someone kicked...they may not understand why they have been kicked, and will not understand that they should not log in at this time or they will rekick that other user..
Also make sure that you set the loggedout time as soon as the user closes his browser (using the global.asax Session_End method)
That's about it..I hope it helps.
Regards,
Max.
Main Topics
Browse All Topics





by: strickddPosted on 2007-08-22 at 06:41:49ID: 19745996
There is no way to access a separate session from the current session. The only way you can really do what you want to do is clear all sessions by resetting the application. I'm sure this is not what you want to do so the next option is to just let the existing session timeout. Usually if someone doesn't log out and then comes back a while later they will be timed-out anyway. Also, once a user closes the browser their session will be closed anyway.