How do I detect when a user has been idle for a certain time and destroy their session in PHP?
I assume you mean 'idle' time. There is no need to calculate that, but you have to store the last (authenticated) access made by that user and reset the counter.
Typically, one would should issue an authentication cookie with a certain timestamp. Upon authentication of the cookie, you compare the current time with the timestamp. If this difference is larger than some threshold, say 5 minutes, you present an error page.
To improve the user experience, you might also want to display a timer to the user so there is no bad surprise.
I would like to have my PHP website destroy a users session if they have been idle for 5 minutes.  If this does happen, I'd like to present the user with a message stating why they were logged out and redirect them to the login page.
What is the best way to handle this?
I am running on php and myadmin.
Thanks
Avinash