wood burning stoves 2.0
The moose likes Servlets and the fly likes session invalidating using session ID???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "session invalidating using session ID????" Watch "session invalidating using session ID????" New topic

session invalidating using session ID????

syed mraza

Joined: Aug 23, 2001
Posts: 28
hi folk
just wondering tht is it possible to invalidate a session using its session Id only??? any help/suggestion/comment woudl be aprriciated. thnx
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

Not sure if I understand what you're trying to do -- or from where you'd like to invalidate a session using only the session ID....
You can only invalidate a session if you have hold of its session object, and you can only get hold of the session object by calling request.getSession() or request.getSession(boolean), the Servlet 2.2 and 2.3 spec do not allow you to look up a session from the sessionID.
You would then call session.invalidate() to invalidate the current session.
- Jessica Bradley
HP Bluestone

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
syed mraza

Joined: Aug 23, 2001
Posts: 28
thnx for replying. yeah thts wht i figured out too actualy i was keeping the session's track using their Id. now something new came up and i found out tht i might have to invalidate a session even b4 it times out in some cases. so i was wondering if there is a way to do so with its session Id. i know there was sessionContext earlier (which has been depricated now) by which it could be done. but not any more.
sjhyam m

Joined: Apr 26, 2001
Posts: 7
Hi syed,
Did you come across any solution for invalidating the session with session id. I too have a similar problem. I am trying to restrict my user to log in twice form different places and use the the application. When the user logs in for the first time, I am allowing him to use the applicaiton or browse the pages. If this user logs in to application from another place/browser at that time, I will catch and send a message that: "You are already logged in". Now I am asking him to work at the place where he logged in first time. But I want to provide a option that upon user request from the second place, I would like to invalidate his session at the first place. It will be similar to what they do in Yahoo/MSN messneger when you log in for the second time.
Hope you have got an idea about this. Please update me if you have any good idea to solve this problem....?
syed mraza

Joined: Aug 23, 2001
Posts: 28
well acutaly i've implemented a singleton for my application which keeps track of the users and their respective sessions. and if a user who has already loged in , logs in again i invalidate the session. i coudlnt find anything to invalidate session using the SessionID so i ahve to keep the session;s reference. and invalidate it if a user re-login b4 his/her session expires.
hope this helps
lets roll.
I agree. Here's the link: http://aspose.com/file-tools
subject: session invalidating using session ID????
It's not a secret anymore!