seadrag0n
seadrag0n

Reputation: 848

efficient way to manually check if user is logged in or not in asp.net

I am working on a asp.net 3.5 application where asp.net membership is not implemented. If a user logs into the application, i am maintaining a flag in the users table which will be set true if the user is logged in and is set to false if the user manually logs out or if the user is idle for more than 5 minutes. If this flag's value is true, other users cannot login into the application using the same user name.

I am using Session_End event of Global.asax file set the flag value as false when the user is idle for more than 5 minutes, but the problem is that sometimes the flag value is not getting updated to false if the user idles for more than 5 minutes which shows that Session_End is not very reliable.

Someone please suggest me an alternative to Session_End for the above scenario.

Upvotes: 0

Views: 652

Answers (2)

realnero
realnero

Reputation: 994

I'd recommend to use Session timeout to forcibly end session. More info can be found here - http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.timeout%28v=vs.110%29.aspx

Did you set any timeout value?

Upvotes: 0

Francis P
Francis P

Reputation: 13655

Use a timespan mechanism. Refresh the timespan on every user action on the server. When timespan is older than 5 minutes, you'll know he is gone.

Upvotes: 1

Related Questions