Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is session object timeout handled in ASP.NET with SQLServer as sessionState mode?

How, or maybe where, is the session timeout handled when you set SQL Server as state handler in an ASP.NET application?

Is it the .NET framwork who after loading session objects from the DB does a judgement on whether or not the objects are expired, or is it a job on the SQL Server itself that takes care of this? The reason I suspect (or even concidered) the latter possibility, is that the script that created the ASPState mentioned something about a ASPState_Job_DeleteExpiredSessions-element.

If it is so that it is an SQL Server job that cleans up, how often does this job trigger and how does it align with the timeout parameter in web.config?

like image 978
Nilzor Avatar asked Apr 05 '11 14:04

Nilzor


1 Answers

From the article linked to by Quantum Elf:

SqlSessionStateStore doesn't actively monitor the Expires field. Instead, it relies on an external agent to scavenge the database and delete expired sessions—sessions whose Expires field holds a date and time less than the current date and time. The ASPState database includes a SQL Server Agent job that periodically (by default, every 60 seconds) calls the stored procedure DeleteExpiredSessions to remove expired sessions.

This means that it's the SQL Server that handles expriation and session object purging, and the SQL Job Agent in particular.

like image 68
Nilzor Avatar answered Oct 18 '22 05:10

Nilzor