Make a table with unique session ID in a DB, and record the last refresh time...then simply check if the ID exists and has a last refresh time lower then 30 seconds.
Record time as 'time()', and simply check if the current time minus the recorded time is bigger then 30, then refresh is allowed.