The Wayback Machine - https://web.archive.org/web/20221029110609/https://github.com/symfony/symfony/discussions/47908
Skip to content

Where flusing database after successful user login to retain login history ? #47908

Unanswered
sdespont asked this question in Q&A
Discussion options

I need to save the login date and time of the website's users after their login.

Because I am using form_login authentication manager, where is the best place to save this data in the database ?

Is it OK to do that in the success_handler by injecting EntityManagerInterface and flush User entity in onAuthenticationSuccess ?

I am asking because I know it is not a good practice to flush database in a listener.

You must be logged in to vote

Replies: 2 suggested answers

Comment options

Any advice?

You must be logged in to vote
0 replies
Comment options

You can listen to the LoginSuccessEvent

https://symfony.com/doc/current/security.html#authentication-events

You must be logged in to vote
0 replies
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.