In my clustered web application, I want to make the User log on at that time only one. when the same user(active) wants to log into the web application more than one at that time in the same browser or another instance browser, Application Should alert the message as 'User has Log on into the application Now'. After the logoff has done, the same user can be able to log into the web application.
How to Make track of User and his Session?.
You can store User Id into the Session object after a successful login i.e. (User Id/Password verification) .
And to stop same User login again , you need to check the same User Id attribute before the login (User Id/Password verification) to see if this User Id already exist. If it does just return the message otherwise let it login again.
Since the same user(ie for eg:user1) has already logged into the application (from different machine)
When the same user(ie.user1)is logging into the application from another machine,I have to cut off the logging and I has to alert the user,(the user (ie user1) has already logged))..
one session per user..
Create a session registry which can be a clustered cache like jboss cache and while login and logout manage that cache...
Query that cache to manage the one login per user...
Follow the following steps:
1.For the first time the user logs in create a session obejct containing the user info.
2. Store the session object in the data base as CLOB or BLOB. This table should have userid as the primary key. You can have others columns as well which maintains the user log history.
3.For every request check whether the logged in user has the active session object in the database. If yes then thorw an Exception saying user is already logged in.
NOTE: Session should be invalidated and made inactive in the databse upon user logout,closing of a browser,and session timeout.