I think what you want to look into is the heartbeat patternhttp://ajaxpatterns.org/Heartbeat
So you'd have some server side code that listens for requests, maybe a webservice called Heartbeat with a method called 'Pulse'
You client side code would periodically call this code to tell the server 'still here!'
NB: You need to implement this carefully. Maybe some script to record 'last key press' time and only call the Pulse method when this is within acceptable range. Otherwise, if you just called it every 30 seconds or whatever, a user could leave the browser open & go on holiday & their session would stay open.