Assuming that you are talking about the HttpSession, you can use the sessionDestroyed() method and implement your functionality, because the sessionDestroyed looks like its being called just before the session is invalidated, from with in this method you can get hold of the HttpSessionEvent from the session event you can get the Session Object and get those values which you have stored in the Session
V 2.3 API says:
sessionDestroyed(HttpSessionEvent se)
public void sessionDestroyed(HttpSessionEvent se)Notification that a session is about to be invalidated.
Parameters:
se - the notification event
-Mallik