File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How to identify a session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to identify a session?" Watch "How to identify a session?" New topic

How to identify a session?

Tim Lincecum

Joined: Aug 30, 2002
Posts: 5
hi all!
I know every session has a unique sessionID
If I keep all userID-sessionID record in my web app.
my question is, when I want to "force" an user to logout,
how do I use sessionID to find that session and kill it??
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

You used to be able to do this using the HttpSessionContext
but as you can see this has been removed for security reasons.
Deprecated As of Java(tm) Servlet API 2.1 for security reasons, with no replacement. This interface will be removed in a future version of this API.

The problem is that application contexts can talk to each other. If you can reach from one web app to another, get the thing that holds some elses session, you can then get and set data on it.
Initially it might sound useful and like a good idea, but consider the case where you (personally) don't control all the app on a server...
If you want to log someone out from the server side, set a session timeout and use a registered HttpSessionBindingEvent to detect when the session times out. Manually maintaining the user and session data is dangerous!
I agree. Here's the link:
subject: How to identify a session?
It's not a secret anymore!