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?
-
This is for an Internet facing site?– Anders AuneFeb 14, 2012 at 6:55
-
No, intranet portal.– Ayyappan AnbalaganFeb 14, 2012 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– Ayyappan AnbalaganFeb 14, 2012 at 9:23
4 Answers
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.
-
<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 Feb 14, 2012 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.– webdes03Feb 14, 2012 at 13:50
-
-
2EDGE-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. Feb 14, 2012 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. Nov 14, 2012 at 13:07
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"
-
4Also 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. Feb 14, 2012 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) Feb 14, 2012 at 9:57
-
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
<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.
-
please call the Timeout method inside jquery document.ready Feb 16, 2012 at 8:44