Hey.
If you want to detect when a user presses a key or scrolls the page, and destroy a session based on that, you will need to use JavaScript and AJAX to trigger the PHP code that actually destroys it.
To do what you are asking, I would do the following:
- Set PHP up so that the session times out after an hour. See this article for details on how to do that.
- Create a PHP ping page that simply "refreshes" the session timeout. It wouldn't have to do anything other than start the session and update whichever timeout method you use (if any).
- Have the JavaScript code monitor the user input. When the user is active, send periodic AJAX requests to the PHP ping page. If he becomes inactive, stop sending the AJAX requests.
The result of this would be that while the user is actively working on a page of your site, his session would remain alive, even though he never really requests anything from the server.