How to limit number of users?

Hmmm...IIS might have something - in ASP directly I think your best bet (and other please chime in if you have ideas so my knowledge can grow too), is to do the following:

1. Have an integer that is specified to store the number of users that is stored in an application variable.

2. In the global OnSessionStart increment that value.
3. In the global OnSessionEnd decrement that value.

I think this has some down falls though but I'm not sure on them. Hopefully someone can provide better enlightenment, but this should get you started.
 
One downside is that you would have to wait for the session timeout before "OnSessionEnd" is called

This would account for the users who dont 'log out' of your application, but just close their browser.

This timeout is something like 20 minutes, from a musty corner of my memory.

This could cause a problem because you might hit your 'connection limit', even though no-one is actually "using" your application! (i.e. they all log in and then simply close their browser)

B.
 
I want limit because of licensing problem. When user buy 5 user licenses then only 5 concurrent users are allow.

If I want to display which user login to system,
can I store Session object in Application object?
So I can list out all the Session users.

What happen if the Session expires?
Will it automatic remove from Application object?
 
Why would you want to store Session objects in the Application object? they are designed to do seperate things and this kind of defeats the whole point. If you want to track the number of users then the suggestion by bri189a above is about the best you can do, but as penfold69 pointed out if users fail to logout correctly then the sessions will remain for up to 20 minutes by default.
Too be honest web applications just aren't designed for this kind of concurrent user licensing model.
 
The method that has been suggested before is about all you can do - track the session start / ends and manually keep track, provide your users with an option to logout. If they do not manually logout then they are likely to have problems as the session will be live for 20 minutes.
Ultimately this is not how web applications are designed to work, concurrent user monitoring is just not something http / web apps are expected to do.
 
Back
Top