You can write a custom authentication handler to perform this task. When the user logs in - you can write Java application logic to perform Stastics/calculations that you want to track. For example - you can determine the last time the user logged in.
To write a custom authen handler - create a Java class that extends DefaultAuthenticationFeedbackHandler and implements these interfaces:
- org.apache.sling.auth.core.spi.AuthenticationHandler
- org.apache.sling.auth.core.spi.AuthenticationFeedbackHandler