Usually, in a rich internet application (RIA), a user with a registered
account can do two different logins from two different workstations and can
maintain two concurrent sessions opened. In some applications we want to
limit the users to one session per account, so we have to take
countermeasures.
A simple method to check if a user is logged is to set a property in the
current HttpSession; in this example in our login function we set
session.setAttribute("username", username);
If there is no username attribute, we will return an error to the user.
When someone starts a session with his account we have to check if there is
already a session opened with that account. We can use an HashMap using the
username as key and the session as value; obviously we have to use the same ... (more)