After the session Expired can we get session id. Is there any method??

Showing Answers 1 - 9 of 9 Answers

sunil

  • Nov 22nd, 2006
 

I hope there is no way to get the session id once the session is expired.

  Was this answer useful?  Yes

Radhakrishna Billa

  • Feb 23rd, 2007
 

HI,

  We can't get the session Id after the session has been destroyed.But there is a mechanism using which one method will be called before the session is going to be destroyed so that we can get the session Id.

We have to use the Listeners to do the same.

eg:
HttpSessionListener-- this  class contains two methods called sessionCreated() which will call after the session is created and the second one is sessionDestroyed() which will call before the session going to be destroyed.

signature of this method and sample code are:

void sessionDestroyed(HttpSessionEvent se){
   HttpSession session=se.getSession();
   String id=session.getId(); // It will give u the session Id
}

we have to register this class as a listener to the application(like mentioned in the web.xml)

regards,
Radhakrishna Billa

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions