Hi everyone,
This is regarding tracking of login and logout actions of users.
I am recording the session creation time and end time using the
HttpSessionBindingListener class. The two methods valueBound() and
valueUnbound() are
invoked. But the getAtrribute() method in the session object returned by
event.getSession()
always give null.
I am storing the userid and a string in the session to indicate if the user
has logged out.
By checking this string's value I can find out if the user has logged out or
the session has timed out.
What I did to solve this problem was to store the sessionid and the userid
in
an external database. When the user logs out, before invalidating the
session, I
put "LoggedOut" in the loginStatus column. In the valueUnbound() event, I
check
the value of the loginStatus column to check if the event has been called
because
of the user logging out or if the session has timed out.
How is it actually done internally? i.e., is there a thread similar to the
garbage
collector which checks the current sessions or is the session invalidated
only
when a request comes from the client. The second option will mean that the
objects
in the session will be occupying memory till the server is shutdown.
Has anyone implemented anything similar to this.
Thanks,
Nagaraj.