best strategy for timing out a transaction/session?

Blootozooxiva

New Member
I'm working on a web application that automates a reservation process using the Google Calendar API and PHP. When the user first selects a date, my script creates a "tentative" event on the Calendar to prevent other users from trying to select the same date. However, to avoid the proliferation of tentative dates created by users that don't follow through, I want to impose a time limit on the transaction process, so that if the user leaves the app or takes too long, the tentative date will be removed from the calendar (and thus available for other users to reserve).We're currently storing the appointments in a MySQL db as well as the Google Cal, so here's my current strategy: when the tentative appointment is first created, store the tentative appointment in the db with a timestamp. Then, schedule a cron job (maybe every hour or so) that scans through the database and removes tentative reservations based on the age of their timestamp (removing them from both the db and the google cal).In theory, this should work. However, my question is this: is there a simpler/more elegant way to do this that I'm not thinking of? Does anyone have a better solution to this problem?
 
Back
Top