Add below mention JavaScript just before closing body tag(</body>) in your Master page
<script>
var logoutUser = false;
var timeoutHnd = null;
var logouTimeInterval = 3000;
function onuser_activite(){
if(logoutUser){
;
}
else{
ResetLogOutTimer();
}
}
function OnTimeoutReached(){
logoutUser = true;
alert("You Session Expired");
window.location.href = "Logout.aspx";
}
function ResetLogOutTimer(){
clearTimeout(timeoutHnd);
timeoutHnd = setTimeout('OnTimeoutReached();',logouTimeInterval);
}
document.body.onclick = onuser_activite;
timeoutHnd = setTimeout('OnTimeoutReached();',logouTimeInterval);
</script>