Session Expiration

Apr 12, 2011 at 10:47 AM
Edited Apr 12, 2011 at 11:06 AM

Has anyone implemented a session expiration using ASPProviders? I read somewhere in documentation that Session_End event in global.asax does not trigger if we are using ASPProviders?

I am facing following problem. If the user closes the browser directly, without logging off, the Table Storage and Blob Storage keeps maintains the session forever.

//The TableStorageSessionStateProvider.cs contains

 public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback)

        {            
// This provider doesn't support expiration callbacks

// so simply return false here            

return false;        

}

How do I clean all the expired sessions from Table and Blob?

Coordinator
Apr 12, 2011 at 11:18 AM

I wanted to add a worker role that cleans up expired sessions from the table storage, does this sound like a good way of doing it? If so then I can add this feature to the solution. The sessions have an expire date after about a month or so after they were created.

Apr 13, 2011 at 3:37 PM

The process could also just piggyback on another method, say when the session is created, to ensure that table stays clean. checking for expired sessions should be minimal since it will be performed when creating sessions as well.

May 24, 2011 at 2:07 PM

I would go also for the piggybacking idea.  Put it in the same workerrole as the email worker. 

Coordinator
Jun 5, 2011 at 3:02 PM
Edited Jun 5, 2011 at 3:04 PM

I've done some research now, and the Session_End event in global.asax is only raised when using InProc, so I can't do any clean up from there. Using a Email Worker "piggyback"-routine, which is in a completely different business logic domain, is against my pride as a system architect :) ... I should either rename the Email worker to something more generic sounding, or I should make another worker. I'm not sure yet as adding another worker may increase the cost of hosting this in Azure. What do you ppl think?

Coordinator
Jul 17, 2011 at 3:45 PM

I have added a clean-up role in V1.3.