Saturday, October 24, 2009

Automatic webpage logout

Below is some javascript that can be added to any page in order to automatically log out a user after a given amount of time.

<script language="javascript">
  //function __logout(msg, loc ) {alert(msg); location.href = loc;}

  //function __startLogoutCountdown(){window.setTimeout("__logout('Login Expired: === \\nThis site uses a security feature that automatically logs you out from your session after 16 minutes. You may login again to continue your session.', '<%=Request.ApplicationPath%>/Logout.aspx');", 960000);};
</script>