Showing posts with label session. Show all posts
Showing posts with label session. Show all posts

Friday, October 19, 2007

Session_End and SessionState mode="SQLServer"

Submit this story to DotNetKicks

A webapp I'm working on now needs to keep track of the number of logged in users at any time. We used to rely on Session_End for deleting sessions. However, this turned out to work only if the SessionState mode was set to InProc.  For other scenarios, Session_End is simply not called. Ever.

So we programmed a background service that polls the database now and then, and deletes from our table the rows that don't exist in the AspState-database (AspState obviously keeps track of timed out sessions and removes them from the table). Clean and simple solution.