This is taken from the Inspinia Theme from {wrap}bootstrap. Click on Miscellaneous and then Idle Timer to see a preview.
This is a JavaScript implementation and it won't check the session directly but it will check for no user input. If it detects (or not detects I should say) any input from the user, then it will show a message. (You can do what you like at this point).
$(function() {
// Set idle time
$( document ).idleTimer( 5000 );
});
$(function() {
$( document ).on( "idle.idleTimer", function(event, elem, obj){
// function you want to fire when the user goes idle
});
$( document ).on( "active.idleTimer", function(event, elem, obj, triggerevent){
// function you want to fire when the user becomes active again
});
});