Frage

I have a need to make a change to a database value at the moment that a user logs out. I can make this happen when the user clicks 'logout', but I need this to happen when a user times out as well. Is there some sort of listener or other such method I can use to achieve this?

Basically, due to SimpleMembership not supporting online user checking, I am forced to use a database field, a boolean, that records if a user has clicked login or logout, but obviously I cannot set this field to "false" if unless they click logout. Hence my need to detect automatic logouts, so to speak.

Any suggestions?

War es hilfreich?

Lösung 2

ASP.NET has session states. So the one you should be interested is the Session_OnEnd event. But you can only use this inProc mode.

Refer to: http://msdn.microsoft.com/en-us/library/ms178583.aspx

Add this to Global.asax

public void Session_OnEnd()
{      
  //Perform your logic.     
}

Andere Tipps

See: How to get notified of session end?

If you're sessions are in-process you can subscribe to the Session_End event. You will eventually (after the session timeout has expired) be notified that the session has ended.

You will not be able to subscribe to any notification that lets you know when the session times out.

Instead, you will need to keep track (most likely in a database) of when the user performed their last action. Then have some sort of job that will periodically check to see those members that have not performed an action in any given time-frame and trigger the logout method.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top