The application is already configured via Spring Session to log user sessions into a SQL database. Now I would like to log the user sessions into my own database table for purposes of tracking user login data. What are some possible ways to do so?
Asked
Active
Viewed 1,614 times
0
-
What is "SQL database" and how is "my own database table " different? – Sheetal Mohan Sharma May 04 '18 at 13:21
-
by SQL database i just meant to say a relational database. from my understanding when you use Spring session, it creates a SPRING_SESSION table in the database you specify in the configuration. I wanted to log data to a table that I create. – user1797298 May 04 '18 at 21:10
2 Answers
3
You can create a bean which implements ApplicationListener<>
, for either AuthenticationSuccessEvent
or InteractiveAuthenticationSuccessEvent
events.
See for further info:

destan
- 4,301
- 3
- 35
- 62
0
The original poster has likely moved on from this question, but others my find this tutorial useful as I did:
Keep Track of Logged In Users with Spring Security
Basically, it makes use of the HttpBindingSessionListener to keep track of a list of currently logged in users.

grant
- 19
- 5