Some cases, our clients (SharePoint Client) may request to change the session time out of SharePoint sites. It is allowed to set timeout of the user session in SharePoint so that users are logged out after certain time of inactivity. Additionally, current page state will be expired based configure timeout. There are multiple ways, we can configure session timeout.
From central Administrator:
Go to SharePoint Central Admin
Go to Application Management
Select Configure Session State
Under Timeout, change the default value stored there.
Power Shell ( SharePoint Management Shell)
This is handy for forms which have to be filled within certain period of time before they expire. Alternatively, if you want to extend the timeout – you can do that.
$spsite = Get-SPSite("[site collection url]")
$webApp = $spsite.WebApplication
$webApp.Enabled = $true
$webApp.Expires = $true
$webApp.Timeout = New-TimeSpan -Hours 2 -Minutes 30
This will enable session expiration and set page content to timeout after 2 hours and 30 minutes.
If you’re using claims authentication and would like for your provider to expire sessions after certain period of inactivity, here is how to do that with Power Shell:
$tokenservice = Get-SPSecurityTokenServiceConfig
$tokenservice.UseSessionCookies = $true
$tokenservice.LogonTokenCacheExpirationWindow = New-TimeSpan -Minutes 5
Logon expiry will be set to 5 mins.