Page 1 of 1

Setting something to work only once every 10 minutes?

Posted: Thu Jul 31, 2003 1:34 pm
by Sephiriz
I have a certain script that I only want a person to be able to execute once every 10 minutes.

I can think of some possiblities as to how to set this, but are there any specific functions that can help me in this, and any simple way I can do this?

I was thinking that you do something with MySql where you make a column, then when you start the script you take the time, and send that time to the Mysql database, and then make a check in the script that it only works if the current time is +10 to that stored in the table.

Any suggestions? Help appreciated very much, this is my first time posting here, so I'm sorry if this seems a stupid question.

Posted: Thu Jul 31, 2003 1:36 pm
by nielsene
if you're on a *nix machine, you can use cron to do this for you

Posted: Thu Jul 31, 2003 1:37 pm
by Sephiriz
Yes, thats a problem I forgot too mention, I do not have Cron enabled on this web server.

Posted: Thu Jul 31, 2003 2:17 pm
by m3rajk
have a table with a timestamp.
each time a user does it it'll first check the timestamp of he last one. if it's less than 10 min ago return an error. otherwise update the row (which will update the timestamp) and allow the user to do that

Posted: Thu Jul 31, 2003 2:30 pm
by Sephiriz
Ok, thanks.

Posted: Sat Aug 02, 2003 11:19 pm
by jmarcv
...or set a 10 minute cookie.