1π
β
A simpler solution would be not tying the survey answers to the user ID. Give the survey response a separate, completely independent ID. When a real user is logged in, create a one-sided association from user to survey response. When the anonymous user registers, add this association as well. (That is, the βownerβ of a survey will be optional.) Afterwards, periodically delete old survey responses that have no owner, and/or ignore outdated ones in queries.
This shifts most of the complexity from the admin app to user registration only. (I.e. when an anonymous user answers a survey, store the response ID in the session. When a new user registers, check the session for response IDs, and then assign it to the user ID.)
π€millimoose
Source:stackexchange.com