Expired sessions are not being deleted from the ASP.NET Session State database.

Problem

This problem usually happens when you move your SharePoint farm to a different database server using SQL Aliases. When you create the Session State Database in SharePoint, it creates a SQL Agent job called <DB Name>_Job_DeleteExpiredSessions. This job runs every minute to clean out the expired sessions from the database. Without it, your database will fill up very quickly and eventually consume all the disk space on your database server.

Solution

You can either re-create the Session State Database using SharePoint Management Shell or you can script to job and re-create it on your new database server.

Method #1

Run SharePoint Management Studio

Disable-SPStateServiceDatabase

Enable-SPSessionStateService -DatabaseName <String> [-DatabaseServer <String>]

Get-SPSessionStateService

You should see your newly created Session State Service Application on the new database server.

Method #2

Login to your old database server and run SQL Management Studio

Expand SQL Server Agent -> Jobs

Locate the job <Session State Database Name>_Job_DeleteExpiredSessions

Right click -> Script Job as -> Create To -> Clipboard

Login to your new database server and run SQL Management Studio

Click on New Query -> Paste

You should see something like:

SE [msdb]
GO
/****** Object:  Job [SessionStateServiceDB_Job_DeleteExpiredSessions]    Script Date: 01/08/2013 14:56:17 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
..

Click on Execute, this will create the job under the SQL Server Agent.

Right click on SQL Server Agent -> Refresh

Expand Jobs and you should see that the job has copied to your new database server.

Right click on it and check the properties / schedule, etc. All settings should be exactly the same as on the old database server.

 

Tags:

One Response to “Expired sessions are not being deleted from the ASP.NET Session State database.”

  1. Jaimie February 1, 2016 at 7:32 pm #

    There is also a health rule for the ASP.Net Session State Service-“Expired sessions are not being deleted from the ASP.NET Session State database.”- that verifies its SQL Agent job is executing and removing expired sessions appropriately.

Leave a Reply

%d bloggers like this: