I don't know how a web application would know if the db was restarted except if you store something like the pid of the mysql instance on disk every time you access the page.
OK, now that I think of it, why not do this: Every time you run the application, save the last_insert_id() to a local file.
Before you run an insert, check that file and compare it to the next auto_increment number
SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE
TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'whatever'
Then, if the local file has the same or greater, set auto_increment to one more than the greater number. If not, don't worry.