tags:

views:

48

answers:

3

Hey

I', working with a small webshop, (includes a simpel online store - no users requires).

I need to find out if an session user haven't "accepted" the payment after.. 5-10 min.

If not, I have to "roll-back" the store and set the current shop sessions to null. Any helps how to do it? Or examples would be great..

thx for now

+1  A: 

One option is to have a last_activity field in your database and check it/update it on each users page loads

Another option is to have a script run every 10 minutes or so via a cron job that cleans up stale sessions

Galen
Even better, store this value in a PHP session then the extra trip to the database won't be required.
TravisO
That could be a better option for him, you should add that as an answer
Galen
+1  A: 

If possible, decouple payment transactions from the store's state; you shouldn't be rolling back the entire store on non-payment, just the transaction / order. Also, a time lock isn't the best way of doing things like this as real-life happenings, internet connection speeds, and general distractions all run the risk of creating situations where a buyer's payment is reversed by mistake. If they are impatient you may lose the sale...

However, without more info about the system in question it's hard to suggest an alternative, so I'd say use a cron job to remove any transactions older than 10 mins that haven't been set to ACCEPTED.

MatW
A: 

I'm not sure, but i think what i'm looking for is a cronjob something like this link

william