How to log off user from SharePoint site, if the user has been inactive for 20 minutes
-
07-12-2019 - |
Question
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?
La solution
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.
Autres conseils
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"
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.