Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How to log off the SharePoint site, if the user is has been inactive for for 20 minutes? Do I need to redirect user to logout page? How would I count the idle time?

share|improve this question
    
This is for an Internet facing site? –  Anders Aune Feb 14 '12 at 6:55
    
No, intranet portal. –  MarsMan Feb 14 '12 at 9:18
    
<script type="text/javascript"> function Timeout(){ var t = setTimeout("RedirectToLogout()", 20*60000); } function RedirectToLogout(){ window.navigate("/_layouts/SignOut.aspx"); } </script> this is the js script i used tried to redirect the page to signout page, but whats happened is if i use this code in managed path like server/site it will redirect to server/_layouts/SignOut.aspx. but it has to redirect to server/site/_layouts/SignOut.aspx –  MarsMan Feb 14 '12 at 9:23
add comment

4 Answers

up vote 11 down vote accepted

You could count the idle time and redirect to signout page with javascript like this:

setTimeout(function(){
      window.location.href = _spPageContextInfo.webServerRelativeUrl + "/_layouts/signout.aspx";
}, 1200000);

Add that javascript to your .master page.

Session termination itself is obviously configured separately (see other answers). Solution above only handles redirection.

share|improve this answer
    
<script type="text/javascript"> function Timeout(){ var t = setTimeout("RedirectToLogout()", 20*60000); } function RedirectToLogout(){ window.navigate("/_layouts/SignOut.aspx"); } </script> this is the js script i used tried to redirect the page to signout page, but whats happened is if i use this code in managed path like server/site it will redirect to server/_layouts/SignOut.aspx. but it has to redirect to server/site/_layouts/SignOut.aspx –  MarsMan Feb 14 '12 at 9:23
    
If you want to use the JavaScript approach, you can either grab the window.location and regex out to get the managed path, or simply use the L_Menu_BaseUrl JavaScript variable that SharePoint generates you. –  webdes03 Feb 14 '12 at 13:50
    
Modified script to include server relative path. –  Jussi Palo Feb 14 '12 at 14:04
1  
EDGE-CASE: If you have a user who has multiple tabs open, and forgets about one of his tabs, after 20 mins (or however long) that tab will log his entire session out, regardless of the activity in the other tabs. –  James Love Feb 14 '12 at 20:53
1  
@TomResing: Thanks for pointing that out. I was only thinking of the redirection as session expiration will occur anyway. Added clarification of this to my answer. –  Jussi Palo Nov 14 '12 at 13:07
show 3 more comments

There is a setting located at web application general settings in the Central Admin ( Central Administration -> Application Management > Web application general settings ) which keeps the security validation for 30 mins by default and then if users tries to access the site. user will get a security prompt.

In SP2010: Central Admin ->Application Management -> Manage Web Application -> Select the specific Web application and from the Ribbon select the "General Settings" -> "General Settings"

share|improve this answer
4  
Also note that this depends on the browser settings. For eg:- If in IE "Automatic Logon with current username and password" is checked, then you wont notice a difference even though the time out has been checked. –  Deepu Nair Feb 14 '12 at 8:08
    
I am not able to access this root. do we have any root likee this.( Central Administration -> Application Management > Web application general settings ) Is that available in SP 2010 ( I fount it It there is manage web application) –  MarsMan Feb 14 '12 at 9:57
    
I have updated my response for SP2010 –  Falak Mahmood Feb 14 '12 at 10:37
add comment

FBA? If so, you can configure this via powershell:

http://blog.petercarson.ca/Pages/SharePoint-2010-Session-Management.aspx

$sts = Get-SPSecurityTokenServiceConfig 
$sts.UseSessionCookies = $true 
$sts.FormsTokenLifetime = (New-Timespan –Minutes 2)
$sts.LogonTokenCacheExpirationWindow = (New-Timespan –Minutes 1)
$sts.Update() 
iisreset
share|improve this answer
add comment
<script type="text/javascript">
    function Timeout(){
        var t = setTimeout("RedirectToLogout()", 20*60000);
    }
    function RedirectToLogout(){
       var path = SP.Utilities.Utility.getLayoutsPageUrl("SignOut.aspx");
       window.navigate(path);
    }
    </script>

i have added this script in body section

<script>
    window.onload=Timeout; 
</script>

Finally this stuff works. Thanks Abi.

share|improve this answer
    
please call the Timeout method inside jquery document.ready –  MarsMan Feb 16 '12 at 8:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.