Make automatic Logout when user is inactive for “X “minutes

1. We can do session management in sharepoint applications or sites. When ever we prepare Public facing websites we have to enable this session management. For example banking applications are the good examples for the session management applications. If we are inactive for 10 mins (more or less), it will automatically signed out after performing any actions.
2. This session management can do for the users who are created through forms based authentication. By default if you login through windows authentication, the session expiration time is 10hrs.
3. First you have to enable the site with Forms based authentication functionality. If you don’t know how to do it, follow my previous post which is documented nicely.
4. After you done with the above step, just need to enable the session with the powershell script.

$sts = Get-SPSecurityTokenServiceConfig 
$sts.UseSessionCookies = $true 
$sts.FormsTokenLifetime = (New-Timespan –Minutes 10)
$sts.LogonTokenCacheExpirationWindow = (New-Timespan –Minutes 10)
$sts.Update() 
iisreset

Note
In above script make sure that you should provide a space between “New-TimeSpan” and “-Minutes 10” terms. Other wise it should throw an error as object not found.
5. Now login with forms based authentication user and check. For testing purpose it is better to give time as 1 or 2mins. If it works fine for you then increase the time and execute the script again.

Good luck.

Advertisements

2 Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s