symfonyauthenticationactionanonymoususer-tracking

Symfony 2 track anonymous user actions in database


I would like to track anonymous user actions as if the user would be authenticated. The goal is to let users perform actions(normally reserved to authenticated users), save it in Database with a special status (not visible until user will log into the application).

For example, an anonymous user reply to a comment. The system detect that the user is not logged in, save the comment with special status 'waiting for authentication'. The system ask user to log in, in order to complete the registration of the comment. User log into the application. The system check for 'waiting for authentication' status and update/associate entries to the user authenticated.

Have you any suggestions / experiences to implement this type of functionality? Maybe Symfony has already in feature/bundle for that?


Solution

  • What you are trying to do is simillar to Lazy Registration, which is a proven concept. It is well implemented here at stackoverflow. It allows you to post messages after providing an email address. It works similar to this one: http://www.90percentofeverything.com/2009/03/16/signup-forms-must-die-heres-how-we-killed-ours/

    However, if you really want to go your way, without asking user for an email address, I would recommend storing data at browser local storage. It would save you a lot of work on backend side. Data would be transferred to the backend only when user registers. This way you will also prevent database pollution with users who never registered. http://blog.teamtreehouse.com/storing-data-on-the-client-with-localstorage