There are most of the time when there is requirement for setting session timeout when user is idle for sometime. Like there are ajax requests going on for users who are logged in e.g notification call, new messages call. But the user is idle or leaves the browser open for long time so in that case you might be need to stop unwanted ajax calls to avoid server overhead.
So There is a jquery script Idle Timer you can use to check user active status. The code is :-
tt_exp = 500000; //set the time in microsecond
//This event will fire when user idle time exceeded.
// can send ajax calls
// can send calls for destroying user session.
// can refresh the window.
// can make an alert.
//This event will fire when user comes back to your website.
// code when user become active.
// calling idle timer plugin.
Make sure you have included Idle Timer Script
The above script will check user mouse movement on your web page and fire the events for user statuses.