Here is a simplified version of what is happening:
The user completes a form.
When storing the form, the row id is stored in the session.
The user then logs in.
The event of a user logging in is caught and the correct row (id taken from session) is then updated with the users id.
Now if the user only completes step 1 and step 2 then abandons the process because they do not want to log in the database is left with rows of data not attributed to a user.
I need to remove these rows.
What would be the best way to achieve this?
Is there a way to do a database transaction that runs across requests, so it can be started before login and committed after log in?
Would a cleanup script running every so often be best, finding no user attributed rows and deleting them?
Or is there another way?