Page 1 of 1
A problem most siteengineers with a db should consider
Posted: Tue Aug 17, 2004 6:10 am
by tores
Hi
Let's say that a user of your site is in the middle of a several-pages-registration. On each page u store the values given by the user. Then suddenly, in the middle of the registration, the user exits your page. What about the now incomplete and useless values he's entered into your db?? How can these be removed?
Anyone got a solution to this problem. Is it possible to notify the server that the user is leaving and trigger a function of some sort that removes the values he entered?
regards tores
Posted: Tue Aug 17, 2004 6:23 am
by Grim...
Store a date/time in the database along with the first set of variables.
At the end of every day, run a page that deletes incomplete logins more than seven days old.
Posted: Tue Aug 17, 2004 6:25 am
by Buddha443556
Why not store the data in session variable till the multi-page process is complete? Then session garbage collection can take care of the problem.
Posted: Tue Aug 17, 2004 8:38 am
by Bill H
..incomplete and useless values he's entered into your db??
It would never occur to me to enter any data into the db before the user has completed entering and indicated that he is finished. Why would anyone do that?
Posted: Tue Aug 17, 2004 9:16 am
by Buddha443556
It would never occur to me to enter any data into the db before the user has completed entering and indicated that he is finished. Why would anyone do that?
Experience is being able to say you made a mistake before. Wisdom is not repeating the same mistakes again.
Re: A problem most siteengineers with a db should consider
Posted: Tue Aug 17, 2004 9:20 am
by JayBird
tores wrote:Hi
Let's say that a user of your site is in the middle of a several-pages-registration. On each page u store the values given by the user. Then suddenly, in the middle of the registration, the user exits your page. What about the now incomplete and useless values he's entered into your db?? How can these be removed?
Anyone got a solution to this problem. Is it possible to notify the server that the user is leaving and trigger a function of some sort that removes the values he entered?
regards tores
It would never occur to me to enter data into a DB until whatever process was finished. Entering data into a DB would eb the last thing that would happen in the process.
Mark
Posted: Tue Aug 17, 2004 9:33 am
by CoderGoblin
On rare occasions (customer doesn't want it and will not accept anything to do with sessions, or legacy code where sessions are an absolute mess and shouldn't really be altered in any way shape or form) it is necessary to place data into a database when not complete. In this instance I would store the necessary data in a temporary area with a timestamp. Once the process is complete move the temporary values into the main db area. All temporary values lasting longer than 7 days or so get wiped via a cron job.
I agree sessions are the way to go but unfortunately what we all think is a good idea is sometimes not allowed

Posted: Tue Aug 17, 2004 9:51 am
by Buddha443556
CoderGoblin wrote:On rare occasions (customer doesn't want it and will not accept anything to do with sessions, or legacy code where sessions are an absolute mess and shouldn't really be altered in any way shape or form) it is necessary to place data into a database when not complete. In this instance I would store the necessary data in a temporary area with a timestamp. Once the process is complete move the temporary values into the main db area. All temporary values lasting longer than 7 days or so get wiped via a cron job.
I agree sessions are the way to go but unfortunately what we all think is a good idea is sometimes not allowed

So true but aren't you just impementing a form of sessions though? Sure your gc is a cron job but isn't a session nothing more than an id, a timestamp and some data? But I agree workarounds are sometimes dictated by the customer and situation.
Posted: Tue Aug 17, 2004 10:20 am
by CoderGoblin
Buddha443556 wrote:
So true but aren't you just impementing a form of sessions though? Sure your gc is a cron job but isn't a session nothing more than an id, a timestamp and some data? But I agree workarounds are sometimes dictated by the customer and situation.
The answer is yes, in reality you are but as far as any customer or "admin" person is concerned you don't use the word session. I have found with a lot of customers doing something similar to what is "dreaded", making sure you truthfully can say 'it does not use X' makes the customer happy whilst allowing maintainable and practical code.
In the short term (first customer contact) you have to develop trust. Later if you develop a good customer relationship and they trust you, you can start influencing their ways of looking at things. It is then you could start reintroducing the idea of "php sessions" pointing out how similar they are to what is currently going on and how it would be minor changes only to convert it and enhance things. The key is developing the trust.