• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

remove one session from another session

 
pavan bukka
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
how to invalidate a httpsession from another httpsession in java

with regards,
b pavan kumar.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the forums, Pavan.

Can you tell us why you want to do that?
 
pavan bukka
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason is, when a user logs in with a user id and password what i do is i save the user object in the httpsession object , when another user tries to login with the same user id i throw him the message that some one has logged in with the same user id and password and this user should be able to invalidate the first user's httpsession.
 
Ayan mallick
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can take help of listener which will implement HttpSessionListener and
ServletRequestListener. and use a map to save session instance and userobject
if it is a new session and before putting the session into map check whether any earlier session carrying same user object or not.

if map has any session carrying same user object then you invalidate that session and add present session to the map.

or else you simply put present session in map.

and the moment session will be destroyed remove that particular session entryset from the map.

why ServletRequestListener is needed because the moment session will be initialized it wont have user object inside it.so you will have to check
with every request and get the session from request check if it is a new session and perform operations on it inside requestInitialized method.

Hope it helps
 
pavan bukka
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply , i will try.

with regards,
bukka pavan kumar.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic