Thursday, March 8, 2012

Auto Log Off after 10 min in SharePoint site


Some time users are required auto log off the SharePoint site after particular time for security. Here is JavaScript to add in CEWB on page.

You can set time in JavaScript and called the default Sign Out page of SharePoint. If you want to set auto log off for one particular page, set the below JavaScript function in CEWB on that page, otherwise for whole SharePoint site add the JavaScript function on master page.

<script type="text/javascript">
//Added for Auto LogOFF after 10 min


    function Timeout(){
        var t = setTimeout("RedirectToLogout()", 10*60000);
    }
    function RedirectToLogout(){
       var path = "http://YouSite/_layouts/SignOut.aspx";
       window.navigate(path);
    }
    </script>
<script>
  window.onload=Timeout;
</script>


Happy Coding 

2 comments:

  1. Thanks for your post and I changed little bit of your code and placed in the master page.
    setTimeout(function(){
    window.location.href = _spPageContextInfo.webServerRelativeUrl + "/_layouts/signout.aspx";
    }, 600000);

    ReplyDelete
  2. In Project Time Management - Is there a function or coding to correct a name that was entered as MTLADS\name?

    ReplyDelete