Wednesday, December 8, 2010

Auto Sign out SharePoint

One of the customer requirements was "If the user is not the using the SharePoint portal in the browser for more than 10 minutes; The session should be ended for security reasons".
To accomplish this  I tried to enable the Session State for the SharePoint site "Which is disabled by default" and changed the Session time out, but it didn't work. So after a lot of research and googling, I decided to do it by JavaScript and with the help of the magic of JQuery:
I added the following java script block in the master page and it works fine , and the customer is satisfied.

<script src="http://code.jquery.com/jquery-1.4.4.js">
 
<script> $(document).ready(function(){  window.setTimeout(  
function(){   ie 
= (document.all) ? 
true : false;
if(ie){ document.execCommand('ClearAuthenticationCache',false);   }
var pathname = window.location.pathname;
window.location='/_layouts/AccessDenied.aspx?loginasanotheruser=true&amp;Source='  
pathname ;  }, 600000); }); 
</script>


I hope it helps you.

No comments:

Post a Comment