I have made a shopping cart where user has to login. I have used stateful session bean to manage the session. Now the problem is that even after shutting down computer, the user is not getting logged off.
Please tell me how to kill a session when user logs out or system is shut down.
I am using JBoss 3.2.1
What kind of "session" are you talking about? The application session, or the statefull session?
In the latter case, the session must be removed with session.remove(). You can achieve this implementing a session listener that gets notified when the user's session expires, and performs the removal.
In the case of a non-web client, where the application can be killed in many ways (unplugging the users PC, for instance), you may not have any chance to detect that situation; the container should detect this (the client that created a statefull session is not there anymore). I guess this should be somewhere in the EJB spec, but I don't quite remember...
Cheers and happy coding,
Adding to Martin's response, if you have a non-web client you could just follow the idea of web sessions - set an expiration on session.
Have a session manager that monitors the open sessions and test them for inactivity.